Please read the documentation...
replies (with the rabbitTemplate as the listener).
replyTo. Your consumer can be a simple POJO method that returns a list of
Objects. Use a JsonMessageConverter in the adapter to convert them to JSON.
Post by Rajasekhar PThank 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.
CONFIGURATION -
public RabbitTemplate rabbitTemplate() {
RabbitTemplate template = new RabbitTemplate(connectionFactory());
template.setRoutingKey(this.queueName);
template.setQueue(this.queueName);
template.setMessageConverter(new JsonMessageConverter());
return template;
}
public ConnectionFactory connectionFactory() {
CachingConnectionFactory connectionFactory = new
CachingConnectionFactory(
"localhost");
connectionFactory.setUsername("guest");
connectionFactory.setPassword("guest");
return connectionFactory;
}
PRODUCER CODE -
String corrId = UUID.randomUUID().toString();
String replyQueueName = *channel*.queueDeclare().getQueue();
MessageProperties prop = new MessageProperties();
prop.setCorrelationId(corrId.getBytes());
prop.setReplyTo(replyQueueName);
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.
Post by Gary Russellhttp://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.
Post by Rajasekhar PHi 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
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss at lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131111/4dc8b993/attachment.htm>