0
votes

I am trying to use spring integration and bit confused about outbound gateway. Below is my question.

This is what I understand about outbound gateway.

Spring integration amqp outbound gateway takes messages from requestChannel and write it to rabbitmq queue (requestQueue) and waits for reply on rabbitmy replyQueue. Once the reply is available, it reads and add it to responseChannel.

The question is, if multiple requests are being sent concurrently by multiple job instances and responses for different requests by different jobs are available on same rabbitmq replyQueue.

Then how does outbound gateway choose responses ? Does it use correlation id to fetch only responses to request sent by the same gateway and ignores other responses ?

1

1 Answers

1
votes

It depends on how the gateway is configured; by default a separate (auto-delete) reply queue is created for each request.

If it is configured with a RabbitTemplate that uses an explicit reply queue (and a reply-listener), the template does the correlation internally, by setting a correlationId on the message. That way, each reply is returned to the proper caller.

You need to be sure to set the reply-timeout on the outbound gateway to a large enough value; it defaults to 5 seconds.

EDIT:

Note that in order to concurrently run jobs (per your other question), you must use the default reply routing and not a dedicated reply queue. Unlike JMS, AMQP does not have a message selector so you can't have multiple gateways using the same reply queue.