How can I retrieve the id of a Transaction started by JBoss ?

Sometimes it an be useful for debugging purpose to retrieve the id of a transaction; one typical scenario could be a transaction started by an EJB deployed as CMT.

The javax.transaction.TransactionManager interface provides two ways to fetch the transaction id:

  • The simplest strategy is to call the toString method to print complete information about the running transaction. That will print also the transaction id.
  • Other than that, you can cast the javax.transaction.Transaction instance to a com.arjuna.ats.jta.transaction.Transaction . Then, call either the get_uid method, which returns the Transaction Uid representation. Example:

com.arjuna.ats.jta.transaction.Transaction tx = (com.arjuna.ats.jta.transaction.Transaction)tx.getTransaction();
System.out.println("Transaction UID" +tx.get_uid());
  • Please note that you need to call the getTxId method to fetch the Xid for the global identifier.

 Viewing Transactions from the JBoss CLI

If you want to fetch the transactions from the CLI, the following command will show all prepared transactions:

ls /profile=default/subsystem=transactions/log-store=log-store/transactions

Then, to view attributes of a Transaction:

/profile=default/subsystem=transactions/log-store=log-store/transactions=0\:gtrw7f000001\:-b11tfg2\:3t4j1r6a\:9:read-resource

Recommended Articles

Set EJB Timeout Period in JBoss/WildFly

Learn how to configure EJB transaction timeouts in JBoss and WildFly for optimal performance.

Transaction Callbacks for EJB and CDI Beans: A Comprehensive Guide

Learn how to receive transaction callbacks for EJB and CDI beans, including beforeCompletion and afterCompletion annotations.

Call an EJB from another application in WildFly using EJB Lookup

Learn how to invoke EJBs from a remote EJB Client using WildFly's EJB lookup feature. This tutorial covers the steps for creating an EJB server project, setting up security, and configuring dependencies.

EJB to EJB Communication in a Cluster with WildFly 31

Learn how to set up EJB communication between a cluster of WildFly servers and an EJB client, enabling dynamic view of the cluster topology.