0

我有一个使用 spring 集成和 amqp 实现的请求/回复。请求可能需要很长时间才能处理(在某些情况下甚至可能需要一个小时),由于某种原因客户端抛出异常 -

Exception in thread "main" org.springframework.integration.handler.ReplyRequiredException: No reply produced by handler 'client', and its 'requiresReply' property is set to true.

我的客户端配置如下。

 <int-amqp:outbound-gateway
        id="client"
        request-channel="in"
        reply-channel="res"
        exchange-name="reportingServer"
        routing-key-expression="'report.req.'+headers.id"
        amqp-template="amqpTemplate" requires-reply="true">
        </int-amqp:outbound-gateway>

我相信回复超时默认值为-1,表示无限期等待,但不确定为什么它不起作用,任何帮助将不胜感激。

在 amqp 中实施如此长时间的等待操作是否还有任何已知问题,或者应该没问题?

谢谢你

4

1 回答 1

1

只要您没有太多并发请求就可以了 - 如果您有无数线程等待回复,它就不会很好地扩展。

如果您需要扩展它,您可以设计一个具有一对出站和入站适配器的异步等价物,但它比使用网关要复杂一些,并且实际实现将取决于您的其余流程。本质上,您必须设置replyTo标头以使回复到达入站适配器。

如果您有一个简单<gateway/>的 AMQP 网关上游,则需要确保replyChannel标头没有丢失。请参阅Header Channel Registry本节

于 2014-10-07T16:34:01.247 回答