[rabbitmq-discuss] How to handle AcknowledgeMode.MANUAL acknowledgements within handleMessage() method at consumer end?

Rajasekhar P sekhar434145 at gmail.com
Thu Jan 9 10:13:58 GMT 2014


Here, after catching the exception I want send it back to the producer, so
that my client will know what kind of error occurred at backend system. As
mentioned above if exception occurred inside the handleMessag method
message will not deleted from the queue, that is fine and to printing that
error message by registering ErrorHandler with the listener container. But,
I want to send that exception to the producer, can you please tell me how
can we send it back to producer?

Error handling at consumer end -

@Override
public void handleError(Throwable t) {
t.printStackTrace();
}


Thanks in advance.



On Thu, Jan 9, 2014 at 10:50 AM, Rajasekhar P <sekhar434145 at gmail.com>wrote:

> Am using ackMode=AUTO and if any exception occurs in handleMessage()
> method message will be deleted from the queue, it requeued as you mentioned
> in the above mail.
>
> Thank you for your support.
>
>
> On Wed, Jan 8, 2014 at 7:29 PM, Gary Russell <grussell at gopivotal.com>wrote:
>
>> However, if you use ackMode=AUTO, the container will take care of your
>> needs - if you throw an exception, the default behavior is to reject (and
>> requeue). If you don't throw an exception, the message will be ack'd.
>>
>>
>> On Wed, Jan 8, 2014 at 8:57 AM, Gary Russell <grussell at gopivotal.com>wrote:
>>
>>> >public void handleMessage(String message) {
>>> >
>>> >}
>>>
>>> This is a MessageListener and doesn't have access to the Channel.
>>>
>>>
>>> >>Section 3.11 in [1] suggests you are supposed to use Channel#basicAck
>>> from RabbitMQ Java client directly.
>>>
>>>
>>> Right, and to do that, you have to use a ChannelAwareMessageListenerthat has a different signature...
>>>
>>> void onMessage(Message message, Channel channel) throws Exception;
>>>
>>>
>>>
>>>
>>>
>>> On Wed, Jan 8, 2014 at 6:25 AM, Michael Klishin <mklishin at gopivotal.com>wrote:
>>>
>>>> On 8 Jan 2014, at 14:41, Rajasekhar P <sekhar434145 at gmail.com> wrote:
>>>>
>>>> > I want to handle acknowledgements manually, because, if any error
>>>> occurs while processing message it should not be deleted from the queue.
>>>> For this I have used AcknowledgeMode.MANUAL , but am not getting how to set
>>>> the acknowledgement after processing the message in handleMessage method.
>>>> Can anyone tell me how to do that?
>>>>
>>>> Section 3.11 in [1] suggests you are supposed to use Channel#basicAck
>>>> from RabbitMQ Java client
>>>> directly.
>>>>
>>>> 1.
>>>> http://docs.spring.io/spring-amqp/docs/1.2.1.BUILD-SNAPSHOT/reference/html/amqp.html#d4e329
>>>>
>>>> MK
>>>>
>>>> Software Engineer, Pivotal/RabbitMQ
>>>>
>>>>
>>>> _______________________________________________
>>>> 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/20140109/4ac029a6/attachment.html>


More information about the rabbitmq-discuss mailing list