[Design of Messaging on JBoss (Messaging/JBoss)] - Re: XARecovery - MQ/Messaging merge
by mskonda
TransactionRepositroy.java
public List getPreparedTransactions()
| {
| ArrayList prepared = new ArrayList();
|
| log.info("Prepared Transaction in gloabalToLocalMap"+globalToLocalMap);
|
| Iterator iter = globalToLocalMap.values().iterator();
| while (iter.hasNext())
| {
| Transaction tx = (Transaction)iter.next();
| if (tx.xid != null && tx.getState() == Transaction.STATE_PREPARED)
| {
| prepared.add(tx.getXid());
| }
| }
| return prepared;
| }
|
| /*
| * Load any prepared transactions into the repository so they can be recovered
| */
| public void loadPreparedTransactions() throws Exception
| {
| List prepared = null;
|
| prepared = persistenceManager.retrievePreparedTransactions();
|
| if (prepared != null)
| {
| Iterator iter = prepared.iterator();
|
| while (iter.hasNext())
| {
| PreparedTxInfo txInfo = (PreparedTxInfo)iter.next();
|
| Transaction tx = createTransaction(txInfo);
| tx.state = Transaction.STATE_PREPARED;
|
| // we have to associate a callback to the prepared transaction
| // --MK
| persistenceManager.associateCallbackToPreparedTx(tx);
|
| //Load the references for this transaction
| }
| }
| }
|
| /**
| * Creates a prepared transaction
| * @param txInfo
| * @return
| * @throws Exception
| */
| private Transaction createTransaction(PreparedTxInfo txInfo) throws Exception {
| System.out.println("PreparedTxInfo:Xid "+txInfo.getTxId());
| if (globalToLocalMap.containsKey(txInfo.getXid()))
| {
| throw new TransactionException("There is already a local tx for global tx " + txInfo.getXid());
| }
|
| //Resurrected tx
| Transaction tx = new Transaction(txInfo.getTxId(), txInfo.getXid());
|
| if (trace) { log.trace("created transaction " + tx); }
|
| globalToLocalMap.put(txInfo.getXid(), tx);
|
| return tx;
| }
|
| public Transaction getPreparedTx(Xid xid) throws Exception
| {
| // the incoming Xid from Arjuna's RM is funny formatted!
| // hence we have to do our way
| // I have to look into this carefully a bit later.
|
| Xid x = new XidImpl(xid.getBranchQualifier(),xid.getFormatId(), xid.getGlobalTransactionId());
|
| Transaction tx = (Transaction)globalToLocalMap.get(x);
| if (tx == null)
| {
| throw new TransactionException("Cannot find local tx for xid:" + xid);
| }
| if (tx.getState() != Transaction.STATE_PREPARED)
| {
| throw new TransactionException("Transaction with xid " + xid + " is not in prepared state");
| }
| return tx;
| }
|
JDBCPersistenceManager.java
public void associateCallbackToPreparedTx(Transaction tx)
| {
| TransactionCallback callback = (TransactionCallback) tx.getKeyedCallback(this);
|
| if (callback == null)
| {
| callback = new TransactionCallback(tx);
|
| tx.addKeyedCallback(callback, this);
| }
| }
|
| public List retrievePreparedTransactions() throws Exception
| {
| Connection conn = null;
| Statement st = null;
| ResultSet rs = null;
| PreparedTxInfo txInfo = null;
| TransactionWrapper wrap = new TransactionWrapper();
|
| try
| {
| List transactions = new ArrayList();
|
| conn = ds.getConnection();
|
| st = conn.createStatement();
| rs = st.executeQuery(selectPreparedTransactions);
|
| while (rs.next())
| {
| //get the exiting tx id --MK START
| long txId = rs.getLong(1);
| byte[] branchQual = rs.getBytes(2);
| int formatId = rs.getInt(3);
| byte[] globalTxId = rs.getBytes(4);
| Xid xid = new XidImpl(branchQual, formatId, globalTxId);
|
| // create a tx info object with the result set detailsdetails
| txInfo = new PreparedTxInfo(txId, xid);
| transactions.add(txInfo);
| }
|
| return transactions;
|
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969505#3969505
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969505
19 years, 7 months
[Design of Messaging on JBoss (Messaging/JBoss)] - Re: XARecovery - MQ/Messaging merge
by mskonda
"timfox" wrote :
| The JBoss TS Recovery manager lives on the client side. How does it get hold of the list of XAResources to recover?
|
You have to pass a parameter to let the JBossTS know who's the provider.
anonymous wrote :
| Does it use ServerConnectionEndpoint::getPreparedTransactions()?
|
yes, the code is modified to get the preparedTransactions (you can see from the trace I've posted)
anonymous wrote :
| When you are creating the Transaction instances from the database and adding to the transation repositiry are you sure you are populating their internal transaction callbacks?
|
This is something I asked team to look at my earlier JBMESSAGING-407 issue. I short, yes, when a transaction is created (resurrected), I associate with a TransactionCallback. See below:
public void associateCallbackToPreparedTx(Transaction tx)
| {
| TransactionCallback callback = (TransactionCallback) tx.getKeyedCallback(this);
|
| if (callback == null)
| {
| callback = new TransactionCallback(tx);
|
| tx.addKeyedCallback(callback, this);
| }
| }
|
*I am adding only a TransactionCallback! I didn't get through much about memory callbacks and others.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969499#3969499
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969499
19 years, 7 months
[Design of Messaging on JBoss (Messaging/JBoss)] - Re: XARecovery - MQ/Messaging merge
by mskonda
2006-09-05 15:55:47,999 TRACE [org.jboss.jms.tx.MessagingXAResource] MessagingXAResource[-2147483640] committing < 131075, 27, 25, 1-a6eddd7:c333:44fd8a7c:17aa6eddd7:c333:44fd8a7c:181 > (two phase)
| 2006-09-05 15:55:47,999 TRACE [org.jboss.jms.tx.ResourceManager] commiting xid < 131075, 27, 25, 1-a6eddd7:c333:44fd8a7c:17aa6eddd7:c333:44fd8a7c:181 >, onePhase=false
| 2006-09-05 15:55:48,001 TRACE [org.jboss.jms.client.container.ClientLogInterceptor] invoking ConnectionDelegate[-2147483641].sendTransaction(TransactionRequest[TWO_PHASE_COMMIT, < 131075, 27, 25, 1-a6eddd7:c333:44fd8a7c:17aa6eddd7:c333:44fd8a7c:181 >])
| 2006-09-05 15:55:48,002 TRACE [org.jboss.jms.client.delegate.DelegateSupport] invoking sendTransaction on server
| 2006-09-05 15:55:48,002 TRACE [org.jboss.jms.server.remoting.JMSServerInvocationHandler] invoking org.jboss.remoting.InvocationRequest@40c4d5
| 2006-09-05 15:55:48,002 TRACE [org.jboss.jms.server.container.ServerLogInterceptor] invoking ConnectionAdvised->ConnectionEndpoint[-2147483641].sendTransaction(TransactionRequest[TWO_PHASE_COMMIT, < 131075, 27, 25, 1-a6eddd7:c333:44fd8a7c:17aa6eddd7:c333:44fd8a7c:181 >])
| 2006-09-05 15:55:48,003 TRACE [org.jboss.jms.server.endpoint.ServerConnectionEndpoint] Two phase commit commit request received
| 2006-09-05 15:55:48,003 INFO [org.jboss.messaging.core.tx.TransactionRepository] ====== Xid(arjuna format) I: ======< 131075, 27, 25, 1-a6eddd7:c333:44fd8a7c:17aa6eddd7:c333:44fd8a7c:181 >
| 2006-09-05 15:55:48,003 INFO [org.jboss.messaging.core.tx.TransactionRepository] ====== Xid:(arjuna2jboss format) II ======org.jboss.messaging.core.tx.XidImpl@3312f2d0
| 2006-09-05 15:55:48,007 INFO [org.jboss.messaging.core.tx.TransactionRepository] ====== Xid already in gloablToLocalMap III ======org.jboss.messaging.core.tx.XidImpl@3312f2d0
| 2006-09-05 15:55:48,008 INFO [org.jboss.messaging.core.tx.TransactionRepository] ====== Tx I : ======: null
| 2006-09-05 15:55:48,008 INFO [org.jboss.messaging.core.tx.TransactionRepository] ====== Tx II: ======: TX(262145):PREPARED
| 2006-09-05 15:55:48,008 INFO [org.jboss.messaging.core.tx.TransactionRepository] ====== Tx using III: ======: TX(262145):PREPARED
| 2006-09-05 15:55:48,008 TRACE [org.jboss.jms.server.endpoint.ServerConnectionEndpoint] Committing TX(262145):PREPARED
| 2006-09-05 15:55:48,009 TRACE [org.jboss.messaging.core.tx.Transaction] executing before commit hooks TX(262145):PREPARED
| 2006-09-05 15:55:48,009 DEBUG [org.jboss.mx.loading.UnifiedClassLoader] New jmx UCL with url null
| 2006-09-05 15:55:48,010 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] setRepository, repository=org.jboss.mx.loading.HeirarchicalLoaderRepository3@e7eec9, cl=org.jboss.mx.loading.UnifiedClassLoader3@168442e{ url=null ,addedOrder=0}
| 2006-09-05 15:55:48,019 TRACE [org.jboss.messaging.core.plugin.JDBCPersistenceManager] UPDATE JMSMessageReference SET State = 'C', TransactionId=NULL WHERE TransactionId = 262145 AND State = '+' removed 1 row(s)
| 2006-09-05 15:55:48,020 TRACE [org.jboss.messaging.core.plugin.JDBCPersistenceManager] DELETE FROM JMSMessageReference WHERE TransactionId = null AND State = '-' updated 0 row(s)
| 2006-09-05 15:55:48,022 TRACE [org.jboss.messaging.core.plugin.JDBCPersistenceManager] DELETE FROM JMSTransaction WHERE TransactionId = 262145 removed 1 row(s)
| 2006-09-05 15:55:48,024 TRACE [org.jboss.messaging.core.tx.Transaction] committed TX(262145):COMMITTED
| 2006-09-05 15:55:48,024 TRACE [org.jboss.messaging.core.tx.Transaction] executing after commit hooks TX(262145):COMMITTED
| 2006-09-05 15:55:48,024 TRACE [org.jboss.messaging.core.tx.Transaction] commit process complete TX(262145):COMMITTED
| 2006-09-05 15:55:48,024 TRACE [org.jboss.jms.server.endpoint.ServerConnectionEndpoint] ConnectionEndpoint[-2147483641] processed transaction successfully
| 2006-09-05 15:55:48,024 TRACE [org.jboss.jms.server.container.ServerLogInterceptor] ConnectionAdvised->ConnectionEndpoint[-2147483641].sendTransaction() OK
| 2006-09-05 15:55:48,024 TRACE [org.jboss.jms.client.delegate.DelegateSupport] got server response for sendTransaction
| 2006-09-05 15:55:48,024 TRACE [org.jboss.jms.client.container.ClientLogInterceptor] ConnectionDelegate[-2147483641].sendTransaction() OK
>From the abvoe trace, you can see the tx has been committed.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969495#3969495
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969495
19 years, 7 months