You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Tushar Nagar <tu...@yahoo.co.in> on 2013/07/18 07:50:19 UTC

Transferring messages to a Dead Letter Queue on a Custom Exception on Message Consumer side.

Hi,

I hv been trying this but was unable to find it anywhere. I hv a scenario
where I hv a queue in ActiveMQ and on the message consumer side If I
encounter an exception while processing that message, I want this message to
be en-queued in the dead letter queue/Poison Queue. The condition here is, I
don't want my consumer to send me the message if an exception occurs. I need
to handle that internally as my consumer is an another application.

It would be really appreciable if anybody can help me with this.

Thanks in advance.

Tushar Nagar



--
View this message in context: http://activemq.2283324.n4.nabble.com/Transferring-messages-to-a-Dead-Letter-Queue-on-a-Custom-Exception-on-Message-Consumer-side-tp4669435.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Transferring messages to a Dead Letter Queue on a Custom Exception on Message Consumer side.

Posted by Christian Posta <ch...@gmail.com>.
Your best bet is to take a look at the test case Gary recommended. Will
probably be easiest.


On Mon, Jul 22, 2013 at 4:50 AM, Tushar Nagar <tu...@yahoo.co.in>wrote:

> Hey, thanks for the reply....
>
> but the thing is, I am not able to see the DLQ in my ActiveMQ web console
> i.e. http://localhost:8161/admin/queues.jsp
> and so I am not able to detect whether my messages hv been enqueued in the
> DLQ or not. when I am running the consumer, the DLQ is session is getting
> rollbacked but the message stays there in the queue. I want this message to
> go to the DLQ on rollback.
>
> I am attaching my activemq.xml, my producer and consumer. It would be
> really
> appreciable if you will tell me whether I am missing on anything or not!!!
> Producer.java
> <http://activemq.2283324.n4.nabble.com/file/n4669564/Producer.java>
> activemq.xml
> <http://activemq.2283324.n4.nabble.com/file/n4669564/activemq.xml>
> Consumer.java
> <http://activemq.2283324.n4.nabble.com/file/n4669564/Consumer.java>
>
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Transferring-messages-to-a-Dead-Letter-Queue-on-a-Custom-Exception-on-Message-Consumer-side-tp4669435p4669564.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta

Re: Transferring messages to a Dead Letter Queue on a Custom Exception on Message Consumer side.

Posted by Tushar Nagar <tu...@yahoo.co.in>.
Hey, thanks for the reply....

but the thing is, I am not able to see the DLQ in my ActiveMQ web console
i.e. http://localhost:8161/admin/queues.jsp
and so I am not able to detect whether my messages hv been enqueued in the
DLQ or not. when I am running the consumer, the DLQ is session is getting
rollbacked but the message stays there in the queue. I want this message to
go to the DLQ on rollback.

I am attaching my activemq.xml, my producer and consumer. It would be really
appreciable if you will tell me whether I am missing on anything or not!!!
Producer.java
<http://activemq.2283324.n4.nabble.com/file/n4669564/Producer.java>  
activemq.xml
<http://activemq.2283324.n4.nabble.com/file/n4669564/activemq.xml>  
Consumer.java
<http://activemq.2283324.n4.nabble.com/file/n4669564/Consumer.java>  




--
View this message in context: http://activemq.2283324.n4.nabble.com/Transferring-messages-to-a-Dead-Letter-Queue-on-a-Custom-Exception-on-Message-Consumer-side-tp4669435p4669564.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Transferring messages to a Dead Letter Queue on a Custom Exception on Message Consumer side.

Posted by Gary Tully <ga...@gmail.com>.
peek at https://github.com/apache/activemq/blob/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L318

On 18 July 2013 06:50, Tushar Nagar <tu...@yahoo.co.in> wrote:
> Hi,
>
> I hv been trying this but was unable to find it anywhere. I hv a scenario
> where I hv a queue in ActiveMQ and on the message consumer side If I
> encounter an exception while processing that message, I want this message to
> be en-queued in the dead letter queue/Poison Queue. The condition here is, I
> don't want my consumer to send me the message if an exception occurs. I need
> to handle that internally as my consumer is an another application.
>
> It would be really appreciable if anybody can help me with this.
>
> Thanks in advance.
>
> Tushar Nagar
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Transferring-messages-to-a-Dead-Letter-Queue-on-a-Custom-Exception-on-Message-Consumer-side-tp4669435.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.



-- 
http://redhat.com
http://blog.garytully.com

Re: Transferring messages to a Dead Letter Queue on a Custom Exception on Message Consumer side.

Posted by Christian Posta <ch...@gmail.com>.
Try using transactions, set max redelivery to 0 and call rollback on
exception.

On Thursday, July 18, 2013, Tushar Nagar wrote:

> Hi,
>
> I hv been trying this but was unable to find it anywhere. I hv a scenario
> where I hv a queue in ActiveMQ and on the message consumer side If I
> encounter an exception while processing that message, I want this message
> to
> be en-queued in the dead letter queue/Poison Queue. The condition here is,
> I
> don't want my consumer to send me the message if an exception occurs. I
> need
> to handle that internally as my consumer is an another application.
>
> It would be really appreciable if anybody can help me with this.
>
> Thanks in advance.
>
> Tushar Nagar
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Transferring-messages-to-a-Dead-Letter-Queue-on-a-Custom-Exception-on-Message-Consumer-side-tp4669435.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>


-- 
*Christian Posta*
http://www.christianposta.com/blog
twitter: @christianposta