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.
javax.transaction.TransactionManager interface provides two ways to fetch the transaction id:
- The simplest strategy is to call the
toStringmethod to print complete information about the running transaction. That will print also the transaction id.
Other than that, you can cast the
javax.transaction.Transactioninstance to a
com.arjuna.ats.jta.transaction.Transaction. Then, call either the
get_uidmethod, 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
getTxIdmethod 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:
Then, to view attributes of a Transaction: