将 spring 从 4.x 迁移到 5.x 和 jdk 17

问题描述 投票:0回答:1

我的应用程序中有 spring 依赖项和 spring 集成依赖项。 我已将 spring 从 4.1.1.RELEASE 迁移到 5.3.39,并将 spring 集成从 2.2.3.RELEASE 迁移到 5.5.20。

我有这样的rabbit mq配置。

<int-amqp:inbound-channel-adapter
        id="testAmqpAdapter" channel="AppTestChnl"
        queue-names="${amqp.queue.test}" connection-factory="connectionFactory"
        auto-startup="true" concurrent-consumers="${amqp.consumer.count}"
        channel-transacted="true" task-executor="taskExecutor"
        prefetch-count="2" tx-size="2" acknowledge-mode="AUTO"
        error-handler="messageErrorHandler" />

当我尝试部署应用程序时,出现两个错误。

  1. 找不到属性 txSize
org.springframework.beans.NotWritablePropertyException: Invalid property 'txSize' of bean class [org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer]: Bean property 'txSize' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
  1. 日志中出现以下错误
14:03:07 [main] INFO  o.s.a.r.c.AbstractConnectionFactory.connectHostPort 650]  - Attempting to connect to: ***:5672
14:03:08 [main] INFO  o.s.a.r.c.AbstractConnectionFactory.createBareConnection 589] -Created new connection: connectionFactory#:0/SimpleConnection@1b1d9ff5 [delegate=amqp://***@***:5672/***, localPort= ***]
14:03:08 [AMQP Connection ***:5672] ERROR o.s.a.r.c.AbstractConnectionFactory$DefaultChannelCloseLogger.log 748]|HOSTNAME=***| - Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'channelName' in vhost '***': received 'direct' but current is 'fanout', class-id=40, method-id=10)
14:03:09 [AMQP Connection ***:5672] ERROR o.s.a.r.c.AbstractConnectionFactory$DefaultChannelCloseLogger.log 748]|HOSTNAME=***| - Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'channelName' in vhost '***': received 'direct' but current is 'fanout', class-id=40, method-id=10)
14:03:11 [AMQP Connection ***:5672] ERROR o.s.a.r.c.AbstractConnectionFactory$DefaultChannelCloseLogger.log 748]|HOSTNAME=***| - Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'channelName' in vhost '***': received 'direct' but current is 'fanout', class-id=40, method-id=10)
14:03:15 [AMQP Connection ***:5672] ERROR o.s.a.r.c.AbstractConnectionFactory$DefaultChannelCloseLogger.log 748]|HOSTNAME=***| - Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'channelName' in vhost '***': received 'direct' but current is 'fanout', class-id=40, method-id=10)
14:03:20 [AMQP Connection ***:5672] ERROR o.s.a.r.c.AbstractConnectionFactory$DefaultChannelCloseLogger.log 748]|HOSTNAME=***| - Shutdown Signal: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - inequivalent arg 'type' for exchange 'channelName' in vhost '***': received 'direct' but current is 'fanout', class-id=40, method-id=10)

对于第一个问题,我注意到 tx-size 可以使用 prefetch-count="2" 属性来处理。 如果采取的话,我没有看到任何错误。 请就这两个问题提出您的建议。谢谢

spring spring-integration java-17 spring5 spring-integration-amqp
1个回答
0
投票

更改是 5 年前进行的:https://github.com/spring-projects/spring-amqp/issues/1032。从那里被替换为

batchSize
。因此,这是 Spring Integration 中的一个错误,我们错过了根据 Spring AMQP 中的上游更改删除该 XML 属性:https://github.com/spring-projects/spring-integration/issues/9695

第二个是应用程序错误。您有一个

channelName
交易所声明为
direct
,但它是 RabbitMQ 代理上的
fanout
。如果这是一个意图,您只需将其从代理中删除并重新运行您的应用程序即可。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.