spring rabbit:reply-listener

596 views
Skip to first unread message

Jaile Sebes

unread,
Jan 26, 2017, 5:02:23 AM1/26/17
to rabbitmq-users
I have the following XML configuration


rabbit:template id="amqpTemplate"
        connection-factory="connectionFactory"
        exchange  ="contrlExchange" 
        reply-queue="tmpQ2"
        reply-address="tmpQ2">
        
    <rabbit:reply-listener/>
</rabbit:template>


template.sendAndReceive( routingKey, message ,corrData);


I get the response but get the exception


15:25:49.480 [amqpTemplate.replyListener-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Received message: (Body:'[B@36f4e764(byte[55])' MessageProperties [headers={}, timestamp=null, messageId=null, userId=null, receivedUserId=null, appId=null, clusterId=null, type=null, correlationId=null, correlationIdString=null, replyTo=null, contentType=application/octet-stream, contentEncoding=null, contentLength=0, deliveryMode=null, receivedDeliveryMode=PERSISTENT, expiration=null, priority=0, redelivered=false, receivedExchange=contrlExchange, receivedRoutingKey=tmpQ2, receivedDelay=null, deliveryTag=2, messageCount=0, consumerTag=amq.ctag--16k8BpCWtvm6zIXyal6MQ, consumerQueue=tmpQ2])
15:25:49.480 [amqpTemplate.replyListener-1] WARN org.springframework.amqp.rabbit.listener.ConditionalRejectingErrorHandler - Execution of Rabbit message listener failed.
org.springframework.amqp.rabbit.listener.exception.ListenerExecutionFailedException: Listener threw exception
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.wrapToListenerExecutionFailedExceptionIfNeeded(AbstractMessageListenerContainer.java:872)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:825)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:713)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$001(SimpleMessageListenerContainer.java:95)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$1.invokeListener(SimpleMessageListenerContainer.java:186)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.invokeListener(SimpleMessageListenerContainer.java:1227)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.executeListener(AbstractMessageListenerContainer.java:683)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.doReceiveAndExecute(SimpleMessageListenerContainer.java:1181)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.receiveAndExecute(SimpleMessageListenerContainer.java:1165)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer.access$1500(SimpleMessageListenerContainer.java:95)
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1367)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: null
at java.lang.String.<init>(String.java:491)
at org.springframework.amqp.rabbit.core.RabbitTemplate.onMessage(RabbitTemplate.java:1708)
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:822)
... 10 common frames omitted
15:25:49.481 [amqpTemplate.replyListener-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Rejecting messages (requeue=true)
15:25:49.481 [amqpTemplate.replyListener-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Retrieving delivery for Consumer@5876a9af: tags=[{amq.ctag--16k8BpCWtvm6zIXyal6MQ=tmpQ2}], channel=Cached Rabbit Channel: com.rabbitmq.client.impl.recovery.AutorecoveringChannel@aed5efd, conn: Proxy@4bd91ecd Shared Rabbit Connection: SimpleConnection@4e89d82a [delegate=amqp://nm...@127.0.0.1:5672/, localPort= 57980], acknowledgeMode=AUTO local queue size=0

Do I need to explicitly Specify a rabbit:reply-listener or is there a default listner 
is it mandatory that at consumer side  I should use receiveAndreply

Thanks in advance
Examples are rare when we try to go with XML configuration

Michael Klishin

unread,
Jan 26, 2017, 5:23:33 AM1/26/17
to rabbitm...@googlegroups.com
Hi,

Spring AMQP maintainers prefer using Stack Overflow for questions, tagged with spring-amqp.
You may get a response there much quicker.

Cheers.

15:25:49.481 [amqpTemplate.replyListener-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Retrieving delivery for Consumer@5876a9af: tags=[{amq.ctag--16k8BpCWtvm6zIXyal6MQ=tmpQ2}], channel=Cached Rabbit Channel: com.rabbitmq.client.impl.recovery.AutorecoveringChannel@aed5efd, conn: Proxy@4bd91ecd Shared Rabbit Connection: SimpleConnection@4e89d82a [delegate=amqp://nmsng@127.0.0.1:5672/, localPort= 57980], acknowledgeMode=AUTO local queue size=0

Do I need to explicitly Specify a rabbit:reply-listener or is there a default listner 
is it mandatory that at consumer side  I should use receiveAndreply

Thanks in advance
Examples are rare when we try to go with XML configuration

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Gary Russell

unread,
Jan 26, 2017, 8:42:27 AM1/26/17
to rabbitm...@googlegroups.com
What version of Spring AMQP are you using? 

Since RabbitMQ implemented direct reply-to [1], it is generally not necessary to use a fixed reply queue any more; that was implemented to avoid creating a temporary queue for each request, which is no longer needed with direct reply-to.

There are still some cases where a fixed reply queue might be warranted (e.g. using an HA queue for replies), so I would like to get to the bottom of the NPE but I can't match the line number without looking at every release version (it looks like it might be 1.6.6).

That said, my best guess is the responding service is not returning the correlationId property (which is used to correlate the reply to the request).

It does look like the RabbitTemplate code is vulnerable for an NullPointerException in that case.

Gary



15:25:49.481 [amqpTemplate.replyListener-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Retrieving delivery for Consumer@5876a9af: tags=[{amq.ctag--16k8BpCWtvm6zIXyal6MQ=tmpQ2}], channel=Cached Rabbit Channel: com.rabbitmq.client.impl.recovery.AutorecoveringChannel@aed5efd, conn: Proxy@4bd91ecd Shared Rabbit Connection: SimpleConnection@4e89d82a [delegate=amqp://nm...@127.0.0.1:5672/, localPort= 57980], acknowledgeMode=AUTO local queue size=0

Do I need to explicitly Specify a rabbit:reply-listener or is there a default listner 
is it mandatory that at consumer side  I should use receiveAndreply

Thanks in advance
Examples are rare when we try to go with XML configuration

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Jaile Sebes

unread,
Feb 3, 2017, 1:03:49 PM2/3/17
to rabbitmq-users
I used spring boot 1.4.3.RELEASE so 
spring-amqp.version>1.6.6.RELEASE</spring-amqp.version>


I used a common bean configuration  file for sender and receiver ( tweaking  tutorial5 of spring amqp samples)

It looks like I used two subscribers , one with rabbit:reply-listener at template side  and another explicitly specifying via
<rabbit:listener-container connection-factory="connectionFactory" >
<rabbit:listener ref="Tut5Receiver"    queue-names="commandQ1" />
</rabbit:listener-container> 

When I commented this it started working , Actually I cleaned up the code to send the full code for debugging clarity may be it also helped.
Thanks Gary for the help
15:25:49.481 [amqpTemplate.replyListener-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Retrieving delivery for Consumer@5876a9af: tags=[{amq.ctag--16k8BpCWtvm6zIXyal6MQ=tmpQ2}], channel=Cached Rabbit Channel: com.rabbitmq.client.impl.recovery.AutorecoveringChannel@aed5efd, conn: Proxy@4bd91ecd Shared Rabbit Connection: SimpleConnection@4e89d82a [delegate=amqp://nmsng@127.0.0.1:5672/, localPort= 57980], acknowledgeMode=AUTO local queue size=0

Do I need to explicitly Specify a rabbit:reply-listener or is there a default listner 
is it mandatory that at consumer side  I should use receiveAndreply

Thanks in advance
Examples are rare when we try to go with XML configuration

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.

To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages