[rabbitmq-discuss] How to configure reply queue?

Gary Russell grussell at gopivotal.com
Tue Nov 12 13:35:59 GMT 2013


You need to return a result from your listener pojo

public Object handleMessage(String msg)

or

public List<Object> handleMessage(String msg)

etc.


On Tue, Nov 12, 2013 at 3:17 AM, Rajasekhar P <sekhar434145 at gmail.com>wrote:

> Hi Russell,
>
> Thanks for the support. I have followed the documentation am getting
> response as null. Below is the producer and consumer code.
>
> PRODUCER -
>
> // rabbittemplate
> public RabbitTemplate rabbitTemplate() {
> RabbitTemplate template = new RabbitTemplate(connectionFactory());
>  template.setRoutingKey(this.queueName);
> template.setQueue(this.queueName);
> template.setMessageConverter(new JsonMessageConverter());
>  return template;
> }
>
> String msg = "CUSTOMER1";
> Object res = this.rabbitTemplate.convertSendAndReceive(msg);
> System.out.println("Message sent :" +msg);
> System.out.println("Response : " + res.toString());
>
> CONSUMER -
>
> SimpleMessageListenerContainer container = new
> SimpleMessageListenerContainer();
>  container.setConnectionFactory(this.connectionFactory);
> container.setQueueNames(this.queueName);
> container.setMessageListener(new *MessageListenerAdapter*(new
> TestMessageHandler(this.queueName), new JsonMessageConverter()));
>  container.start();
>
>
>        // receive messages
> public void handleMessage(String msg) {
>  System.out.println("Received  :" + msg);
> }
>
> *Result - *
> Message sent :CUSTOMER1
> java.lang.NullPointerException
>
>
> Here, inside handleMessage based on message I want get the results from DB
> and need to send back. Am confusing how set the response to that
> client(Producer)?
>
>
> <<snip>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20131112/7622ed25/attachment.htm>


More information about the rabbitmq-discuss mailing list