0

When I send reply messages to the same queue I connected to as a consumer, my consumer immediately try to consume this message again. But how to send it as reply without any further consumption?

onMessage(...){
      byte[] arr = SerializationUtils.serialize(res);
      //compute result message
      Message resMessage = new Message(arr, composeMessageProperties(null));
      message.getMessageProperties().setReplyTo("thesamequeue");
      //handle result
      handleResult(resMessage, message, channel);
}
avalon
  • 2,231
  • 3
  • 24
  • 49
  • https://www.rabbitmq.com/tutorials/tutorial-six-java.html also seems to describe that pattern. (not spring specific though) – zapl May 24 '16 at 19:41

1 Answers1

4

Avalon,

JMS Request/Reply patterns use 2 queues.

The first queue (Request queue) is used to take requests in an process it. The second queue (Reply queue) is used to send the response to. Another listener (inside or outside your context) can then in turn read the response from your reply queue and perform logic accordingly.

Using 2 queues helps in the separation on concern. In your context, the first queue listener needs to process the request and put the response in your reply queue. That response, will then be processed by some other process/system ...

Pat B
  • 1,915
  • 23
  • 40