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 <claus.ib...@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 <ephemeris.lap...@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

Reply via email to