spring-boot - AMQP ConvertSendAndReceive 无法从 Spring Boot 1.5 迁移到 2

标签 spring-boot rabbitmq migration

我正在将代码从 Spring Boot 1.5.x 迁移到 2.0.3.RELEASE。

它使用 RabbitMQ 使用 convertSendAndReceive(...) 方法对一组远程引擎进行 RPC 样式调用。

在 1.5 中一切正常,但在迁移的代码中失败。

日志记录最初显示

SimpleConsumer [queue=amq.rabbitmq.reply-to, consumerTag=amq.ctag-39fo5C1y6q8J9OevWDN3_A identity=6ffebba9] started 

消息到达引擎并被正确处理。

但是,返回值为空,并且记录以下内容

ERROR o.s.amqp.rabbit.core.RabbitTemplate No correlation header in reply

在 1.5 中,我们没有向调用者添加关联 ID。我们现在需要这样做还是还需要做其他事情?

TIA。

最佳答案

来自the Spring amqp docs

With versions earlier than verion 2.0, the RabbitTemplate created a new consumer for each request and canceled the consumer when the reply was received (or timed out). Now, the template uses a DirectReplyToMessageListenerContainer instead, allowing the consumers to be reused; the template still takes care of correlating the replies so there is no danger of a late reply going to a different sender. If you want to revert to the previous behavior, set property useDirectReplyToContainer (direct-reply-to-container when using XML configuration) to false.

例如...

    rabbitTemplate.setUseDirectReplyToContainer(false);

关于spring-boot - AMQP ConvertSendAndReceive 无法从 Spring Boot 1.5 迁移到 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52328210/

相关文章:

java - spring security 在重定向到 logout.jsp 时给出错误

java.io.IOException : invalid constant type: 19 at 5 异常

rabbitmq - 我可以在商业应用中使用Mozilla Public License 1.1(MPL)吗?

rabbitmq - 从一个 Docker 容器连接到另一个

java - 如何在 spring boot 中创建自定义注解?

java - Spring Boot 延迟 Flyway 初始化循环依赖

python - 是否可以在 Python 中将 RabbitMQ 直接回复功能与 Pika 生成器使用者一起使用?

SQL Server - 生成没有主键的脚本

android - 没有这样的属性 : variantConfiguration for class:

mysql - EF6 迁移 Mysql 连接器 6.9 在收集 latin1_swedish_ci 时成功,但在 utf8 或 utf8mb4 时出错