简体   繁体   中英

IBM XMS: CommittableTransaction() vs session transaction, is any of them global?

I'm using transactions to read and acknowledge messages on a IBM queue and I'm wondering if a session created with connection.CreateSession(true, AcknowledgeMode.SessionTransacted) locks a message globally when multiple instances of consumers are reading from the same queue?

Background: I have written a small .NET Core Background Service that fetches messages of a queue using IBM XMS. Instances of this service will be hosted on two different servers (load-balanced) and each service will connect to the same queue. My worry is that since two different consumers on different servers are reading from the same queue, they might try to consume the same message.

I recently came across the SimpleXAConsumer example where a CommittableTransaction() -object was used instead of the session-transaction. The documentation states that:

"When XA transaction is in use, the transaction control is through Distributed Transaction Coordinator (DTC) global transactions and it is not though XMS sessions."

... which makes me believe that XMS session-transactions aren't global unless the CommittableTransaction()-object is used.

It would be great if someone could confirm:

  1. If CommittableTransaction() must be used to create a global transaction.
  2. If a global transaction locks a message so that no other consumers may consume it.

If an application gets a message in a transacted session, then that message will not be visible to other applications (and hence can't get it). If the application commits the transaction using session.commit() method, then the message is permanently removed from the queue. On the other hand, that message becomes available to other consumers (or to the same consumer) if the message is rolled back by the application.

Another point to note: The AcknowledgeMode parameter in connection.createSession() method has no effect if the first parameter is true - meaning a transacted session is being created. When using transacted session, applications must use commit or rollback methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM