Search code examples
spring-integrationspring-amqpqpid

spring amqp ReplyRequiredException


I have a request/reply implemented using spring integration and amqp. The requests may take long time to process (they may take even an hour for some cases) , for some reason the client throws exception -

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

My client config is below.

 <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>

I believe reply-timeout default value is -1, means wait indefinitely, but not sure why its not working, any help would be appreciated.

Also are there any known issues with implementing such long waiting operations in amqp or it should be just fine?

Thank You


Solution

  • It will be fine as long as you don't have too many concurrent requests - it won't scale very well if you have gazillions of threads hanging waiting for a reply.

    If you need to scale it, you could devise an asynchronous equivalent with a pair of outbound and inbound adapters, but it's a little more involved than using a gateway and the actual implementation will depend on the rest of your flow. Essentially you'll have to set up the replyTo header to cause the reply to come to the inbound adapter.

    If you have a simple <gateway/> upstream of the AMQP gateway, you'll need to be sure that the replyChannel header is not lost. See Header Channel Registry in this section.