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 acom.arjuna.ats.jta.transaction.Transaction
. Then, call either theget_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