You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ephemeris Lappis <ep...@gmail.com> on 2024/03/11 13:12:41 UTC

Camel JMS & transaction : redelivery conditions ignored

Hello.

It seems that the JMS consumer ignores the redelivery conditions that
I set on my route :

        <route id=" fifi1-jms">
            <from
uri="jms:fifi1?connectionFactory=#aliceJMS&amp;transacted=true" />
            <transacted />
            <onException>
                <exception>java.lang.Exception</exception>
                <redeliveryPolicy disableRedelivery="true" />
                <rollback markRollbackOnly="true" />
            </onException>
            <convertBodyTo type="String" />
            <choice>
                <when>
                    <simple>${body} == 'BAD'</simple>
                    <log message="It's bad !" />
                    <transform>
                        <groovy>0 / 0</groovy>
                    </transform>
                </when>
            </choice>
            <log message="Message has been processed : ${body}" />
        </route>

In fact, the message is not rolled back but delivered 7 times. I'd
like the rollback put the message to a DLQ queue at the first
execution.

I've tried with/without "transacted" option or/and statement, and
with/without "rollback" but it doesn't change anything...

I also switched between "disableRedelivery" and "maximumRedeliveries"
: no difference.

I've probably misunderstood how it works :( !

Any experts for help ?

Thanks in advance.

Regards.

Re: Camel JMS & transaction : redelivery conditions ignored

Posted by Ephemeris Lappis <ep...@gmail.com>.
Hello.Claus !

Well ! after more tests, I can confirm that on the broker side all
works as expected. I've also found some way to set set the route such
a way that failing messages are moved to the DLQ the same way they are
when processed by applications.

        <route id=" fifi1-jms">
            <from
uri="jms:fifi1?connectionFactory=#aliceJMS&amp;transacted=true" />
            <!-- <transacted /> -->
            <onException>
                <exception>java.lang.Exception</exception>
                <redeliveryPolicy maximumRedeliveries="0" />
                <log message="Exception for '${body}' !!!" />
            </onException>
            <convertBodyTo type="String" />
            <choice>
                <when>
                    <simple>${body} contains 'KO'</simple>
                    <log message="It's bad !" />
                    <transform>
                        <groovy>0 / 0</groovy>
                    </transform>
                </when>
            </choice>
            <log message="Message has been processed : '${body}'" />
        </route>

The "transacted=true" on the endpoint seems to be enough to change the
auto-acknowledge mode, and make the consumer code produce a rollback
that makes the broker move the message to the DLQ. This way, messages
are also delivered only once, according to the
"maximumRedeliveries=0".

The route itself is not "transacted".

Could you please confirm that this way only uses a local JMS
transaction manager, or does the XA PlatformTransactionbManager also
participate to the operations ?

Thanks again.

Regards.


Le lun. 11 mars 2024 à 17:07, Claus Ibsen <cl...@gmail.com> a écrit :
>
> Hi
>
> You need to set this on the broker side, it's the one that does the
> redelivery.
> Every broker has their own settings for DLQ and redelivery.
>
> On Mon, Mar 11, 2024 at 2:20 PM Ephemeris Lappis <ep...@gmail.com>
> wrote:
>
> > Hello.
> >
> > It seems that the JMS consumer ignores the redelivery conditions that
> > I set on my route :
> >
> >         <route id=" fifi1-jms">
> >             <from
> > uri="jms:fifi1?connectionFactory=#aliceJMS&amp;transacted=true" />
> >             <transacted />
> >             <onException>
> >                 <exception>java.lang.Exception</exception>
> >                 <redeliveryPolicy disableRedelivery="true" />
> >                 <rollback markRollbackOnly="true" />
> >             </onException>
> >             <convertBodyTo type="String" />
> >             <choice>
> >                 <when>
> >                     <simple>${body} == 'BAD'</simple>
> >                     <log message="It's bad !" />
> >                     <transform>
> >                         <groovy>0 / 0</groovy>
> >                     </transform>
> >                 </when>
> >             </choice>
> >             <log message="Message has been processed : ${body}" />
> >         </route>
> >
> > In fact, the message is not rolled back but delivered 7 times. I'd
> > like the rollback put the message to a DLQ queue at the first
> > execution.
> >
> > I've tried with/without "transacted" option or/and statement, and
> > with/without "rollback" but it doesn't change anything...
> >
> > I also switched between "disableRedelivery" and "maximumRedeliveries"
> > : no difference.
> >
> > I've probably misunderstood how it works :( !
> >
> > Any experts for help ?
> >
> > Thanks in advance.
> >
> > Regards.
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel JMS & transaction : redelivery conditions ignored

Posted by Ephemeris Lappis <ep...@gmail.com>.
Hello Claus.

I'm not sure that I should change anything on the broker side : with
the same ActiveMQ, java applications with a similar connection factory
configuration (maximumRedeliveries=0) actually do a rollback on
failing messages processing, and the broker moves them to DLQ queues.
These applications are spring boot based applications with no XA.

I don't understand why without any exception handling in my camel
route, the message is processed only once, and, as it's managed with
"auto acknowledge" (default mode), a failing message is simply read
and lost. This is a suitable behavior for almost all our use cases,
but for some of them we'd need to save failing messages in DLQ.

Another idea ???

Thanks again.

Regards.

Le lun. 11 mars 2024 à 17:07, Claus Ibsen <cl...@gmail.com> a écrit :
>
> Hi
>
> You need to set this on the broker side, it's the one that does the
> redelivery.
> Every broker has their own settings for DLQ and redelivery.
>
> On Mon, Mar 11, 2024 at 2:20 PM Ephemeris Lappis <ep...@gmail.com>
> wrote:
>
> > Hello.
> >
> > It seems that the JMS consumer ignores the redelivery conditions that
> > I set on my route :
> >
> >         <route id=" fifi1-jms">
> >             <from
> > uri="jms:fifi1?connectionFactory=#aliceJMS&amp;transacted=true" />
> >             <transacted />
> >             <onException>
> >                 <exception>java.lang.Exception</exception>
> >                 <redeliveryPolicy disableRedelivery="true" />
> >                 <rollback markRollbackOnly="true" />
> >             </onException>
> >             <convertBodyTo type="String" />
> >             <choice>
> >                 <when>
> >                     <simple>${body} == 'BAD'</simple>
> >                     <log message="It's bad !" />
> >                     <transform>
> >                         <groovy>0 / 0</groovy>
> >                     </transform>
> >                 </when>
> >             </choice>
> >             <log message="Message has been processed : ${body}" />
> >         </route>
> >
> > In fact, the message is not rolled back but delivered 7 times. I'd
> > like the rollback put the message to a DLQ queue at the first
> > execution.
> >
> > I've tried with/without "transacted" option or/and statement, and
> > with/without "rollback" but it doesn't change anything...
> >
> > I also switched between "disableRedelivery" and "maximumRedeliveries"
> > : no difference.
> >
> > I've probably misunderstood how it works :( !
> >
> > Any experts for help ?
> >
> > Thanks in advance.
> >
> > Regards.
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2

Re: Camel JMS & transaction : redelivery conditions ignored

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You need to set this on the broker side, it's the one that does the
redelivery.
Every broker has their own settings for DLQ and redelivery.

On Mon, Mar 11, 2024 at 2:20 PM Ephemeris Lappis <ep...@gmail.com>
wrote:

> Hello.
>
> It seems that the JMS consumer ignores the redelivery conditions that
> I set on my route :
>
>         <route id=" fifi1-jms">
>             <from
> uri="jms:fifi1?connectionFactory=#aliceJMS&amp;transacted=true" />
>             <transacted />
>             <onException>
>                 <exception>java.lang.Exception</exception>
>                 <redeliveryPolicy disableRedelivery="true" />
>                 <rollback markRollbackOnly="true" />
>             </onException>
>             <convertBodyTo type="String" />
>             <choice>
>                 <when>
>                     <simple>${body} == 'BAD'</simple>
>                     <log message="It's bad !" />
>                     <transform>
>                         <groovy>0 / 0</groovy>
>                     </transform>
>                 </when>
>             </choice>
>             <log message="Message has been processed : ${body}" />
>         </route>
>
> In fact, the message is not rolled back but delivered 7 times. I'd
> like the rollback put the message to a DLQ queue at the first
> execution.
>
> I've tried with/without "transacted" option or/and statement, and
> with/without "rollback" but it doesn't change anything...
>
> I also switched between "disableRedelivery" and "maximumRedeliveries"
> : no difference.
>
> I've probably misunderstood how it works :( !
>
> Any experts for help ?
>
> Thanks in advance.
>
> Regards.
>


-- 
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2