You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Marc Boorshtein <mb...@gmail.com> on 2014/09/10 12:41:45 UTC

Is it possible to add a property to a message prior to rollback?

I'm trying to add a stacktrace to a message if its been rolled back as a
property.  Is this possible?

Thanks
Marc

Re: Is it possible to add a property to a message prior to rollback?

Posted by Matt Pavlovich <ma...@gmail.com>.
Mark-

Another approach is to consume the message, add your headers and then produce it back to the DLQ within a transaction on the same session. That will maintain reliability, and allow you to enrich the message with some root cause information.

-Matt

On Sep 11, 2014, at 7:08 AM, Marc Boorshtein <mb...@gmail.com> wrote:

> Ah. Ok, that makes sense. Is that the standard way to handle exceptions
> with JMS?  Or is it vendor dependent?
> 
> Thanks
> Marc
> On Sep 11, 2014 6:38 AM, "Gary Tully" <ga...@gmail.com> wrote:
> 
>> see
>> https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L317
>> 
>> an exception thrown from on message will force a rollback. There is an
>> internal try catch around the up call to onMessage that traps and
>> stores the exception.
>> 
>> On 10 September 2014 16:38, Marc Boorshtein <mb...@gmail.com> wrote:
>>> Thats what I'm looking for to get the exception out of the failed
>> message,
>>> but how do I set it when I fail the message?  There's no arguments to the
>>> session.rollback() method and I don't see anything on the message its
>> self.
>>> 
>>> 
>>> Any help is greatly appreciated.
>>> 
>>> Thanks
>>> Marc
>>> 
>>> On Wed, Sep 10, 2014 at 10:10 AM, Gary Tully <ga...@gmail.com>
>> wrote:
>>> 
>>>> not really.
>>>> 
>>>> Peek at
>>>> 
>> https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L285
>>>> for a unit test that covers the setting of the dlqDeliveryFailureCause
>>>> property on a message in the DLQ.
>>>> 
>>>> if a listener fails with an exception the cause (as as string) is
>>>> propagated back to the broker in the poison ack and gets added to the
>>>> message when it is added to the DLQ. A browser of the DLQ can see the
>>>> cause property.
>>>> 
>>>> On 10 September 2014 11:41, Marc Boorshtein <mb...@gmail.com>
>> wrote:
>>>>> I'm trying to add a stacktrace to a message if its been rolled back
>> as a
>>>>> property.  Is this possible?
>>>>> 
>>>>> Thanks
>>>>> Marc
>>>> 
>>>> 
>>>> 
>>>> --
>>>> http://redhat.com
>>>> http://blog.garytully.com
>>>> 
>> 
>> 
>> 
>> --
>> http://redhat.com
>> http://blog.garytully.com
>> 


Re: Is it possible to add a property to a message prior to rollback?

Posted by Marc Boorshtein <mb...@gmail.com>.
Ah. Ok, that makes sense. Is that the standard way to handle exceptions
with JMS?  Or is it vendor dependent?

Thanks
Marc
On Sep 11, 2014 6:38 AM, "Gary Tully" <ga...@gmail.com> wrote:

> see
> https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L317
>
> an exception thrown from on message will force a rollback. There is an
> internal try catch around the up call to onMessage that traps and
> stores the exception.
>
> On 10 September 2014 16:38, Marc Boorshtein <mb...@gmail.com> wrote:
> > Thats what I'm looking for to get the exception out of the failed
> message,
> > but how do I set it when I fail the message?  There's no arguments to the
> > session.rollback() method and I don't see anything on the message its
> self.
> >
> >
> > Any help is greatly appreciated.
> >
> > Thanks
> > Marc
> >
> > On Wed, Sep 10, 2014 at 10:10 AM, Gary Tully <ga...@gmail.com>
> wrote:
> >
> >> not really.
> >>
> >> Peek at
> >>
> https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L285
> >> for a unit test that covers the setting of the dlqDeliveryFailureCause
> >> property on a message in the DLQ.
> >>
> >> if a listener fails with an exception the cause (as as string) is
> >> propagated back to the broker in the poison ack and gets added to the
> >> message when it is added to the DLQ. A browser of the DLQ can see the
> >> cause property.
> >>
> >> On 10 September 2014 11:41, Marc Boorshtein <mb...@gmail.com>
> wrote:
> >> > I'm trying to add a stacktrace to a message if its been rolled back
> as a
> >> > property.  Is this possible?
> >> >
> >> > Thanks
> >> > Marc
> >>
> >>
> >>
> >> --
> >> http://redhat.com
> >> http://blog.garytully.com
> >>
>
>
>
> --
> http://redhat.com
> http://blog.garytully.com
>

Re: Is it possible to add a property to a message prior to rollback?

Posted by Gary Tully <ga...@gmail.com>.
see https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L317

an exception thrown from on message will force a rollback. There is an
internal try catch around the up call to onMessage that traps and
stores the exception.

On 10 September 2014 16:38, Marc Boorshtein <mb...@gmail.com> wrote:
> Thats what I'm looking for to get the exception out of the failed message,
> but how do I set it when I fail the message?  There's no arguments to the
> session.rollback() method and I don't see anything on the message its self.
>
>
> Any help is greatly appreciated.
>
> Thanks
> Marc
>
> On Wed, Sep 10, 2014 at 10:10 AM, Gary Tully <ga...@gmail.com> wrote:
>
>> not really.
>>
>> Peek at
>> https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L285
>> for a unit test that covers the setting of the dlqDeliveryFailureCause
>> property on a message in the DLQ.
>>
>> if a listener fails with an exception the cause (as as string) is
>> propagated back to the broker in the poison ack and gets added to the
>> message when it is added to the DLQ. A browser of the DLQ can see the
>> cause property.
>>
>> On 10 September 2014 11:41, Marc Boorshtein <mb...@gmail.com> wrote:
>> > I'm trying to add a stacktrace to a message if its been rolled back as a
>> > property.  Is this possible?
>> >
>> > Thanks
>> > Marc
>>
>>
>>
>> --
>> http://redhat.com
>> http://blog.garytully.com
>>



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

Re: Is it possible to add a property to a message prior to rollback?

Posted by Marc Boorshtein <mb...@gmail.com>.
Thats what I'm looking for to get the exception out of the failed message,
but how do I set it when I fail the message?  There's no arguments to the
session.rollback() method and I don't see anything on the message its self.


Any help is greatly appreciated.

Thanks
Marc

On Wed, Sep 10, 2014 at 10:10 AM, Gary Tully <ga...@gmail.com> wrote:

> not really.
>
> Peek at
> https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L285
> for a unit test that covers the setting of the dlqDeliveryFailureCause
> property on a message in the DLQ.
>
> if a listener fails with an exception the cause (as as string) is
> propagated back to the broker in the poison ack and gets added to the
> message when it is added to the DLQ. A browser of the DLQ can see the
> cause property.
>
> On 10 September 2014 11:41, Marc Boorshtein <mb...@gmail.com> wrote:
> > I'm trying to add a stacktrace to a message if its been rolled back as a
> > property.  Is this possible?
> >
> > Thanks
> > Marc
>
>
>
> --
> http://redhat.com
> http://blog.garytully.com
>

Re: Is it possible to add a property to a message prior to rollback?

Posted by Gary Tully <ga...@gmail.com>.
not really.

Peek at https://github.com/apache/activemq/blob/d54e0d6ab590b6a6148a5e2629c45b95d3f40eb8/activemq-unit-tests/src/test/java/org/apache/activemq/MessageListenerRedeliveryTest.java#L285
for a unit test that covers the setting of the dlqDeliveryFailureCause
property on a message in the DLQ.

if a listener fails with an exception the cause (as as string) is
propagated back to the broker in the poison ack and gets added to the
message when it is added to the DLQ. A browser of the DLQ can see the
cause property.

On 10 September 2014 11:41, Marc Boorshtein <mb...@gmail.com> wrote:
> I'm trying to add a stacktrace to a message if its been rolled back as a
> property.  Is this possible?
>
> Thanks
> Marc



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