Hi Ben,
we experienced a similar behaviour on widlfly + activeq-rar with your exact
use case while using XA for both database and broker connections.
>From our checks both XA connections seemed configured correctly, we
supposed the problem was caused by the commit on phase 2 of the "2PC
algorithm" beeing faster on the broker.
We reconfigured activemq with concurrentStoreAndDispatchQueues="false" and
the problem went away.
I'm not an activemq expert but from what I understood
concurrentStoreAndDispatchQueues="true" is the default beaviour and allows
for messages to be delivered to consumers when they are in memory and not
yet committed to the broker journal.

I would also suggest you to enable redeliveries on the broker side
(requires schedulerSupport="true") and DLQ per each queue policy.

If you application server supports the scenario of an XA transaction
composed of:
 * 1 non XA connection (usually the db)
 * 1 or more XA connections (usually the broker)
you could take advantage of this 2PC algorithm optimization: this
configuration should guarantee that the database commit is visibile when
commit on the broker happens.

Regards,
 Marco


Il giorno ven 20 ago 2021 alle ore 21:23 Justin Bertram <jbert...@apache.org>
ha scritto:

> > write message 2 to message queue (containing ID of record in DB)
>
> In my estimation, this is the step that is not participating in the JTA
> transaction started by the MDB. I assume the connection factory you're
> using here is either looked up in JNDI manually or is injected somehow. How
> this connection factory is configured in the application server is the real
> issue. If it's coming from the ActiveMQ JCA resource adapter then any
> connections created with it should be automatically enlisted in the ongoing
> JTA transaction. However, if not then that would explain the failure. Can
> you clarify this point?
>
>
> Justin
>
> On Mon, Aug 16, 2021 at 11:39 AM Ben Pirt <b...@madetech.com> wrote:
>
> > Hi Justin,
> > Thanks for your reply and apologies for the delayed response - I'm just
> > back from holiday.
> >
> > We're using Container Managed Transactions in our MDBs but when we
> inspect
> > the type of the connection factory in the bean during runtime it is the
> > non-XA version that seems to be being used.
> >
> > I believe the DB is using XA correctly as when we switch just the message
> > queue back to IBM MQ we no longer see the issue.
> >
> > In terms of the program flow we do the following:
> > - consume message 1 as MDB
> > - (lots of processing!)
> > - write to DB
> > - write message 2 to message queue (containing ID of record in DB)
> >
> > And then
> > - consume message 2 from another MDB
> > - read record from DB
> > - app blows up because record is not there / committed
> >
> > (FYI, this is an old app we're modernising so we're trying to keep the
> > application changes to a minimum if we can)
> >
> > Open Liberty docs are lacking on this unfortunately.
> >
> > All the best,
> > Ben
> >
> > > On 31 Jul 2021, at 17:44, Justin Bertram <jbert...@apache.org> wrote:
> > >
> > > In a Java EE server MDBs are executed with configurable transaction
> > > semantics. By default, container-managed transaction semantics are used
> > > which incorporate the consumption of the message by the MDB into a JTA
> > > (which is XA) transaction which includes all other enlisted resources
> > (e.g.
> > > databases, JMS servers, etc.). When using bean-managed transaction
> > > semantics the consumption of the message by the MDB will *not* be part
> > of a
> > > transaction. What kind of transaction semantics are configured for your
> > MDB?
> > >
> > > XA capable resources (e.g. database connections, JMS connections, etc.)
> > > should of course be used at each step. The inbound adapter of the JCA
> RA
> > > used to receive the message by the MDB should already be using XA
> > > implicitly if you're using container-managed transactions. Can you
> > confirm
> > > that your database connection is using XA properly? Are you sending the
> > JMS
> > > message to another ActiveMQ broker or the same ActiveMQ from which you
> > > consumed the message with your MDB or perhaps a non-ActiveMQ JMS
> server?
> > > How exactly is the connection factory configured which you're using to
> > send
> > > the message? Configuring XA support for such resources is
> > > provider-specific. Have you consulted Open Liberty documentation on
> this
> > > point of configuration?
> > >
> > >
> > > Justin
> > >
> > > On Sat, Jul 31, 2021 at 1:26 AM Ben Pirt <b...@madetech.com> wrote:
> > >
> > >> We're modernising an existing enterprise Java application that relies
> on
> > >> XA. It is a message oriented architecture and we're finding race
> > conditions
> > >> are occurring sporadically.
> > >> We receive a message into a Message Driven Bean, interact with the
> > >> database and then fire off another message to another MDB that expects
> > data
> > >> to be in the DB, however because it's not all wrapped up in one
> > transaction
> > >> the data isn't there when the second MDB starts processing, so it
> blows
> > up.
> > >>
> > >> Hope that makes sense!
> > >> Cheers,
> > >> Ben
> > >>
> > >>> On 30 Jul 2021, at 22:42, Justin Bertram <jbert...@apache.org>
> wrote:
> > >>>
> > >>> What behavior do you expect versus what you actually observe? In
> other
> > >>> words, what exactly isn't working?
> > >>>
> > >>> Also, what is your XA use-case?
> > >>>
> > >>>
> > >>> Justin
> > >>>
> > >>> On Fri, Jul 30, 2021 at 4:33 PM Ben Pirt <b...@madetech.com> wrote:
> > >>>
> > >>>> Hi Justin, we're using JCA with the resource adapter.
> > >>>>
> > >>>> We've defined the RA, the Queue Connection Factory and the
> Activation
> > >> Spec
> > >>>> in the server.xml configuration file.
> > >>>>
> > >>>> Cheers,
> > >>>> Ben
> > >>>>
> > >>>>> On 30 Jul 2021, at 22:28, Justin Bertram <jbert...@apache.org>
> > wrote:
> > >>>>>
> > >>>>> I'm not too familiar with Open Liberty. Can you be more specific
> > about
> > >>>> how
> > >>>>> you're attempting to integrate? Are you using plain JMS or JCA via
> > the
> > >>>>> ActiveMQ resource adapter?
> > >>>>>
> > >>>>>
> > >>>>> Justin
> > >>>>>
> > >>>>> On Fri, Jul 30, 2021 at 7:38 AM Ben Pirt <b...@madetech.com> wrote:
> > >>>>>
> > >>>>>> Hello all,
> > >>>>>> I wonder if anyone might be able to help us out - we're trying to
> > use
> > >>>>>> ActiveMQ with Open Liberty but we're struggling to get it using
> the
> > XA
> > >>>>>> version of the Queue Connection Factory - does anyone have any
> idea
> > >> how
> > >>>> we
> > >>>>>> might be able to get XA working on this platform? All help
> > >> appreciated!
> > >>>>>> Thanks,
> > >>>>>> Ben
> > >>>>>>
> > >>>>>>
> > >>>>
> > >>>>
> > >>
> > >>
> >
> >
>

Reply via email to