[rabbitmq-discuss] How to configure reply queue?

Rajasekhar P sekhar434145 at gmail.com
Mon Nov 11 14:56:30 GMT 2013

Thank you Russell for the response. Still am stuck with achieving above
program, could please tell where am failing while doing above code. Below
is the code at producer end.


public RabbitTemplate rabbitTemplate() {
RabbitTemplate template = new RabbitTemplate(connectionFactory());
template.setMessageConverter(new JsonMessageConverter());
return template;

public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(
return connectionFactory;


String corrId = UUID.randomUUID().toString();
String replyQueueName = *channel*.queueDeclare().getQueue();
 MessageProperties prop = new MessageProperties();
Message message = new Message(query.getBytes(), prop);
Message msg = rabbitTemplate.sendAndReceive(message);

Is this correct at producer end? Here how to Channel to retrieve
reqplyQueueName? Could you please correct me on this and please tell me how
to write consumer code to send the result(List of Objects) in JSON format
back to that particular request in replyqueue? Thanks in advance.

On Fri, Nov 8, 2013 at 7:20 PM, Gary Russell <grussell at gopivotal.com> wrote:

> http://docs.spring.io/spring-amqp/reference/html/amqp.html#request-reply
> The simplest is to configure the RabbitTemplate to use a fixed reply
> queue, with a reply listener, and use one of it's
> convertSendAndReceive(...) (or sendAndReceive) methods; the template will
> take care of the correlation.
> If you want to do it asynchronously and do your own correlation (get the
> reply asynchronously on another thread) just use one of the send() methods
> and wire up a listener container to get the results.
> On Fri, Nov 8, 2013 at 12:36 AM, Rajasekhar P <sekhar434145 at gmail.com>wrote:
>> Hi Team,
>> We are trying to make asynchronous call in RabbitMQ using Spring AMQP,
>> could any one please tell me how to configure *replyqueue,
>> correlationId, (properties) *using spring amqp?
>>  String corrId = java.util.UUID.randomUUID().toString();
>>  BasicProperties props = new BasicProperties
>>                                 .Builder()
>>                                 .correlationId(corrId)
>>                                 .replyTo(replyQueueName)
>>                                 .build();
>>  channel.basicPublish("", requestQueueName, props, message.getBytes());
>> Thanks in advance.
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131111/42fb0ee1/attachment.htm>

More information about the rabbitmq-discuss mailing list