Tuesday, June 12, 2012

Difference between XA resource register && Synchronization Listener && Last resource Gammit


Transaction synchronization

Transaction synchronization allows the application server to be notified before and after the transaction completes. For each transaction started, the application server may optionally register a Synchronization call back object to be invoked by the transaction manager:

The beforeCompletion method is called prior to the start of the two-phase transaction complete process. This call is executed in the same transaction context of the caller who initiates the TransactionManager.commit or the call is executed with no transaction context if Transaction.commit is used.

The afterCompletion method is called after the transaction has completed. The status of the transaction is supplied in the parameter. This method is executed without a transaction context.

Logs With Synchronization


(One mysql Xa resource and rest infinispan caches register as synchronization)

 11: 2012-06-12 10:58:30,604 [serviceTaskExecutor-26] WARN  atomikos.println:107  - Attempt to create a transaction with a timeout that exceeds com.atomikos.icatch.max_timeout - truncating to: 300000
 12: 2012-06-12 10:58:30,605 [serviceTaskExecutor-26] INFO  atomikos.println:110  - createCompositeTransaction ( 500000 ): created new ROOT transaction with id tm_tspex-app-container_10428400061
 14: 2012-06-12 10:58:30,606 [serviceTaskExecutor-26] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130343238343030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393934 ) for transaction tm_tspex-app-container_10428400061
 15: 2012-06-12 10:58:30,607 [serviceTaskExecutor-26] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238343030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393934 , XAResource.TMNOFLAGS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e
 16: 2012-06-12 10:58:30,607 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 20: 2012-06-12 10:58:30,641 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@60401ebd ) for transaction tm_tspex-app-container_10428400061
 21: 2012-06-12 10:58:30,641 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@4cd63ee8 ) for transaction tm_tspex-app-container_10428400061
 22: 2012-06-12 10:58:30,642 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@6335b062 ) for transaction tm_tspex-app-container_10428400061
 24: 2012-06-12 10:58:30,643 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@61de2f59 ) for transaction tm_tspex-app-container_10428400061
 25: 2012-06-12 10:58:30,643 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@3fb801c4 ) for transaction tm_tspex-app-container_10428400061
 26: 2012-06-12 10:58:30,644 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 29: 2012-06-12 10:58:30,645 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 33: 2012-06-12 10:58:30,669 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@8658edb ) for transaction tm_tspex-app-container_10428400061
 34: 2012-06-12 10:58:30,670 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 35: 2012-06-12 10:58:30,736 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 41: 2012-06-12 10:58:30,780 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@443bfd3 ) for transaction tm_tspex-app-container_10428400061
 44: 2012-06-12 10:58:30,781 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@5e2fe41a ) for transaction tm_tspex-app-container_10428400061
 45: 2012-06-12 10:58:30,782 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@199ae4c6 ) for transaction tm_tspex-app-container_10428400061
 55: 2012-06-12 10:58:30,784 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 57: 2012-06-12 10:58:30,784 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 59: 2012-06-12 10:58:30,785 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 60: 2012-06-12 10:58:30,837 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 62: 2012-06-12 10:58:30,838 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@9325ee79 ) for transaction tm_tspex-app-container_10428400061
 64: 2012-06-12 10:58:30,840 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@3f5018a0 ) for transaction tm_tspex-app-container_10428400061
 70: 2012-06-12 10:58:30,843 [serviceTaskExecutor-26] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238343030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393934 , XAResource.TMSUCCESS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e
 72: 2012-06-12 10:58:30,844 [serviceTaskExecutor-26] INFO  atomikos.println:110  - commit() done (by application) of transaction tm_tspex-app-container_10428400061
 73: 2012-06-12 10:58:30,889 [Atomikos:488] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238343030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393934 ) returning OK on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e
 74: 2012-06-12 10:58:30,890 [Atomikos:488] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238343030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393934 , false ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e
 75: 2012-06-12 10:58:30,913 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f19} org.infinispan.transaction.synchronization.SynchronizationAdapter@f38
 76: 2012-06-12 10:58:30,913 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f18} org.infinispan.transaction.synchronization.SynchronizationAdapter@f37
 77: 2012-06-12 10:58:30,914 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f16} org.infinispan.transaction.synchronization.SynchronizationAdapter@f35
 80: 2012-06-12 10:58:30,916 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=[TSSEDEV5-34849], isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f1a} org.infinispan.transaction.synchronization.SynchronizationAdapter@f39
 81: 2012-06-12 10:58:30,916 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f17} org.infinispan.transaction.synchronization.SynchronizationAdapter@f36
 82: 2012-06-12 10:58:30,917 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f15} org.infinispan.transaction.synchronization.SynchronizationAdapter@f34
 83: 2012-06-12 10:58:30,917 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f14} org.infinispan.transaction.synchronization.SynchronizationAdapter@f33
 84: 2012-06-12 10:58:30,917 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f13} org.infinispan.transaction.synchronization.SynchronizationAdapter@f32
 85: 2012-06-12 10:58:30,918 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f11} org.infinispan.transaction.synchronization.SynchronizationAdapter@f30
 86: 2012-06-12 10:58:30,918 [serviceTaskExecutor-26] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10428400061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f12} org.infinispan.transaction.synchronization.SynchronizationAdapter@f31
105: 2012-06-12 10:58:30,924 [serviceTaskExecutor-26] WARN  atomikos.println:107  - Attempt to create a transaction with a timeout that exceeds com.atomikos.icatch.max_timeout - truncating to: 300000
106: 2012-06-12 10:58:30,925 [serviceTaskExecutor-26] INFO  atomikos.println:110  - createCompositeTransaction ( 500000 ): created new ROOT transaction with id tm_tspex-app-container_10428500061
107: 2012-06-12 10:58:30,925 [serviceTaskExecutor-26] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130343238353030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393935 ) for transaction tm_tspex-app-container_10428500061
108: 2012-06-12 10:58:30,926 [serviceTaskExecutor-26] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238353030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393935 , XAResource.TMNOFLAGS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e
109: 2012-06-12 10:58:30,926 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@94dac718 ) for transaction tm_tspex-app-container_10428500061
110: 2012-06-12 10:58:30,927 [serviceTaskExecutor-26] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@94dac718 ) for transaction tm_tspex-app-container_10428500061
111: 2012-06-12 10:58:30,928 [serviceTaskExecutor-26] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238353030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393935 , XAResource.TMSUCCESS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e
113: 2012-06-12 10:58:30,929 [serviceTaskExecutor-26] INFO  atomikos.println:110  - commit() done (by application) of transaction tm_tspex-app-container_10428500061
116: 2012-06-12 10:58:30,930 [MatchingEngine-8] WARN  atomikos.println:107  - Attempt to create a transaction with a timeout that exceeds com.atomikos.icatch.max_timeout - truncating to: 300000
117: 2012-06-12 10:58:30,930 [MatchingEngine-8] INFO  atomikos.println:110  - createCompositeTransaction ( 500000 ): created new ROOT transaction with id tm_tspex-app-container_10428600061
118: 2012-06-12 10:58:30,931 [MatchingEngine-8] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.icatch.jta.Sync2Sync@54f3b495 ) for transaction tm_tspex-app-container_10428600061
119: 2012-06-12 10:58:30,931 [MatchingEngine-8] INFO  atomikos.println:110  - commit() done (by application) of transaction tm_tspex-app-container_10428600061
120: 2012-06-12 10:58:30,932 [MatchingEngine-8] INFO  atomikos.println:110  - afterCompletion ( STATUS_COMMITTED ) called  on Synchronization: SynchronizationAdapter{localTransaction=LocalTransaction{remoteLockedNodes=[TSSEDEV5-34849], isMarkedForRollback=false, transaction=tm_tspex-app-container_10428600061, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.synchronization.SyncLocalTransaction@f1b} org.infinispan.transaction.synchronization.SynchronizationAdapter@f3a
123: 2012-06-12 10:58:30,947 [Atomikos:488] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238353030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393935 ) returning OK on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e
124: 2012-06-12 10:58:30,948 [Atomikos:488] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130343238353030303631:746D5F74737065782D6170702D636F6E7461696E65725F3132393935 , false ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@28333b1e

With XA Resource
(Mysql and Infinispan caches as XA resources)

With XA, each resource get added to a list when it is used, and when the transaction is committed separate prepare calls are sent to each of the resources. Once the prepare calls are successful, commit calls are sent to each of the resources to commit the transactions.



 10: 2012-06-12 11:13:39,506 [serviceTaskExecutor-5] INFO  atomikos.println:110  - createCompositeTransaction ( 300000 ): created new ROOT transaction with id tm_tspex-app-container_10173700062
 12: 2012-06-12 11:13:39,508 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373436 ) for transaction tm_tspex-app-container_10173700062
 13: 2012-06-12 11:13:39,509 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373436 , XAResource.TMNOFLAGS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a
 14: 2012-06-12 11:13:39,510 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 18: 2012-06-12 11:13:39,513 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373437 ) for transaction tm_tspex-app-container_10173700062
 19: 2012-06-12 11:13:39,514 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373437 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@4ff}
 20: 2012-06-12 11:13:39,515 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373438 ) for transaction tm_tspex-app-container_10173700062
 21: 2012-06-12 11:13:39,516 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373438 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@500}
 22: 2012-06-12 11:13:39,517 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373439 ) for transaction tm_tspex-app-container_10173700062
 23: 2012-06-12 11:13:39,518 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373439 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@501}
 24: 2012-06-12 11:13:39,519 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 27: 2012-06-12 11:13:39,522 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373530 ) for transaction tm_tspex-app-container_10173700062
 28: 2012-06-12 11:13:39,523 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373530 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@502}
 29: 2012-06-12 11:13:39,543 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373531 ) for transaction tm_tspex-app-container_10173700062
 30: 2012-06-12 11:13:39,544 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373531 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@503}
 31: 2012-06-12 11:13:39,544 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 34: 2012-06-12 11:13:39,546 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 38: 2012-06-12 11:13:39,548 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373532 ) for transaction tm_tspex-app-container_10173700062
 39: 2012-06-12 11:13:39,548 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373532 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@504}
 40: 2012-06-12 11:13:39,549 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 41: 2012-06-12 11:13:39,560 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 52: 2012-06-12 11:13:39,715 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373533 ) for transaction tm_tspex-app-container_10173700062
 53: 2012-06-12 11:13:39,715 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373533 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@505}
 56: 2012-06-12 11:13:39,721 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373534 ) for transaction tm_tspex-app-container_10173700062
 57: 2012-06-12 11:13:39,722 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373534 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@506}
 58: 2012-06-12 11:13:39,722 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373535 ) for transaction tm_tspex-app-container_10173700062
 59: 2012-06-12 11:13:39,722 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373535 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@507}
 68: 2012-06-12 11:13:39,725 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 70: 2012-06-12 11:13:39,726 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 71: 2012-06-12 11:13:39,727 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 72: 2012-06-12 11:13:39,728 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 74: 2012-06-12 11:13:39,729 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@da5de36a ) for transaction tm_tspex-app-container_10173700062
 76: 2012-06-12 11:13:39,730 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373536 ) for transaction tm_tspex-app-container_10173700062
 77: 2012-06-12 11:13:39,730 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373536 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@508}
 85: 2012-06-12 11:13:39,733 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373436 , XAResource.TMSUCCESS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a
 86: 2012-06-12 11:13:39,733 [serviceTaskExecutor-5] INFO  atomikos.println:110  - commit() done (by application) of transaction tm_tspex-app-container_10173700062
 87: 2012-06-12 11:13:39,733 [Atomikos:6] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373437 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1747} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@4ff}
 88: 2012-06-12 11:13:39,734 [Atomikos:10] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373534 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1754} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@506}
 89: 2012-06-12 11:13:39,737 [Atomikos:10] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373534 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1754} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@506}
 90: 2012-06-12 11:13:39,734 [Atomikos:7] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373532 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1752} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@504}
 91: 2012-06-12 11:13:39,737 [Atomikos:12] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373536 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1756} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@508}
 92: 2012-06-12 11:13:39,739 [Atomikos:12] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373536 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1756} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@508}
 93: 2012-06-12 11:13:39,734 [Atomikos:3] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373438 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1748} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@500}
 94: 2012-06-12 11:13:39,739 [Atomikos:3] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373438 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1748} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@500}
 95: 2012-06-12 11:13:39,734 [Atomikos:5] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373531 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1751} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@503}
 96: 2012-06-12 11:13:39,740 [Atomikos:5] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373531 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1751} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@503}
 97: 2012-06-12 11:13:39,734 [Atomikos:4] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373439 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1749} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@501}
 98: 2012-06-12 11:13:39,740 [Atomikos:4] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373439 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1749} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@501}
 99: 2012-06-12 11:13:39,734 [Atomikos:1] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373530 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1750} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@502}
100: 2012-06-12 11:13:39,737 [Atomikos:7] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373532 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1752} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@504}
101: 2012-06-12 11:13:39,737 [Atomikos:9] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373533 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1753} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@505}
102: 2012-06-12 11:13:39,734 [Atomikos:6] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373437 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1747} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@4ff}
103: 2012-06-12 11:13:39,734 [Atomikos:11] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373535 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062tm_tspex-app-container_11755} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@507}
104: 2012-06-12 11:13:39,743 [Atomikos:11] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373535 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062tm_tspex-app-container_11755} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@507}
105: 2012-06-12 11:13:39,742 [Atomikos:9] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373533 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1753} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@505}
106: 2012-06-12 11:13:39,740 [Atomikos:1] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373530 ) returning OK on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1750} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@502}
107: 2012-06-12 11:13:39,767 [Atomikos:8] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373436 ) returning OK on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a
108: 2012-06-12 11:13:39,767 [Atomikos:8] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373436 , false ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a
109: 2012-06-12 11:13:39,767 [Atomikos:3] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373534 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1754} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@506}
110: 2012-06-12 11:13:39,767 [Atomikos:5] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373533 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1753} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@505}
111: 2012-06-12 11:13:39,767 [Atomikos:4] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373532 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1752} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@504}
112: 2012-06-12 11:13:39,767 [Atomikos:11] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373439 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1749} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@501}
113: 2012-06-12 11:13:39,767 [Atomikos:7] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373531 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1751} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@503}
114: 2012-06-12 11:13:39,767 [Atomikos:9] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373438 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1748} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@500}
115: 2012-06-12 11:13:39,767 [Atomikos:1] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373437 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1747} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@4ff}
117: 2012-06-12 11:13:39,767 [Atomikos:12] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373535 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062tm_tspex-app-container_11755} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@507}
118: 2012-06-12 11:13:39,767 [Atomikos:6] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373530 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1750} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@502}
119: 2012-06-12 11:13:39,767 [Atomikos:10] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733373030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373536 , false ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173700062TransactionXaAdapter{localTransaction=LocalXa1756} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173700062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@508}
139: 2012-06-12 11:13:39,811 [MatchingEngine-8] INFO  atomikos.println:110  - createCompositeTransaction ( 300000 ): created new ROOT transaction with id tm_tspex-app-container_10173800062
140: 2012-06-12 11:13:39,811 [MatchingEngine-8] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733383030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373537 ) for transaction tm_tspex-app-container_10173800062
141: 2012-06-12 11:13:39,811 [MatchingEngine-8] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733383030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373537 , XAResource.TMNOFLAGS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=null} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173800062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@509}
142: 2012-06-12 11:13:39,812 [MatchingEngine-8] INFO  atomikos.println:110  - commit() done (by application) of transaction tm_tspex-app-container_10173800062
143: 2012-06-12 11:13:39,812 [Atomikos:8] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733383030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373537 , XAResource.TMSUCCESS ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173800062TransactionXaAdapter{localTransaction=LocalXa1757} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173800062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@509}
144: 2012-06-12 11:13:39,812 [Atomikos:8] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733383030303632:5472616E73616374696F6E5861416461707465727B6C6F63616C5472616E73616374696F6E3D4C6F63616C586131373537 , true ) on resource TransactionXaAdapter{localTransaction=LocalXa represented by XAResource instance TransactionXaAdapter{localTransaction=LocalXaTransaction{xid=tm_tspex-app-container_10173800062TransactionXaAdapter{localTransaction=LocalXa1757} LocalTransaction{remoteLockedNodes=null, isMarkedForRollback=false, transaction=tm_tspex-app-container_10173800062, lockedKeys=null, backupKeyLocks=null, viewId=0} org.infinispan.transaction.xa.LocalXaTransaction@509}
156: 2012-06-12 11:13:39,820 [serviceTaskExecutor-5] INFO  atomikos.println:110  - createCompositeTransaction ( 300000 ): created new ROOT transaction with id tm_tspex-app-container_10173900062
157: 2012-06-12 11:13:39,821 [serviceTaskExecutor-5] INFO  atomikos.println:110  - addParticipant ( XAResourceTransaction: 746D5F74737065782D6170702D636F6E7461696E65725F3130313733393030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373538 ) for transaction tm_tspex-app-container_10173900062
158: 2012-06-12 11:13:39,822 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.start ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733393030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373538 , XAResource.TMNOFLAGS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a
159: 2012-06-12 11:13:39,822 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@ddc794a8 ) for transaction tm_tspex-app-container_10173900062
160: 2012-06-12 11:13:39,823 [serviceTaskExecutor-5] INFO  atomikos.println:110  - registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@ddc794a8 ) for transaction tm_tspex-app-container_10173900062
161: 2012-06-12 11:13:39,824 [serviceTaskExecutor-5] INFO  atomikos.println:110  - XAResource.end ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733393030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373538 , XAResource.TMSUCCESS ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a
162: 2012-06-12 11:13:39,824 [serviceTaskExecutor-5] INFO  atomikos.println:110  - commit() done (by application) of transaction tm_tspex-app-container_10173900062
163: 2012-06-12 11:13:39,843 [Atomikos:8] INFO  atomikos.println:110  - XAResource.prepare ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733393030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373538 ) returning OK on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a
164: 2012-06-12 11:13:39,843 [Atomikos:8] INFO  atomikos.println:110  - XAResource.commit ( 746D5F74737065782D6170702D636F6E7461696E65725F3130313733393030303632:746D5F74737065782D6170702D636F6E7461696E65725F3131373538 , false ) on resource MAIN-ATOMIKOS-CONNECTION represented by XAResource instance com.mysql.jdbc.jdbc2.optional.JDBC4SuspendableXAConnection@4e49879a




Last Resource Commit Optimization (LRCO)

Although the XA transaction protocol is designed to provide ACID properties by using a two-phase commit protocol, model may not always be appropriate. Sometimes it is necessary to allow a non-XA-aware resource manager to participate in a transaction. This is often the case with data stores that do not support distributed transactions.

In this situation, you can use a technique known as Last Resource Commit Optimization (LRCO). This is sometimes called the Last Resource Gambit. The one-phase-aware resource is processed last in the prepare phase of the transaction, at which time an attempt is made to commit it. If the attempt is successful, the transaction log is written and the remaining resources go through the phase-two commit. If the last resource fails to commit, the transaction is rolled back. Although this protocol allows most transactions to complete normally, some errors can cause an inconsistent transaction outcome. For this reason, use LRCO as a last resort. When a single is used in a transaction, the LRCO is automatically applied to it. In other situations, you can designate a last resource by using a special marker interface. Refer to the JBoss Transactions Programmer's Guide for more details.


Ref : http://docs.redhat.com/docs


Thursday, June 7, 2012

JTA Transaction Manager(XA) - Analysis


Requirements
We needs JTA complaint XA transaction manager since we have multiple resources
  • Database - Mysql
  • Cache - Infinispan
Both of these resources support XA - JTA transactions. - Mysql through com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.
Alternatives for transaction manager 
We also need to choose a connection pool framework for database which is XA complaint. Hence options
Picking the right combination
  1. Atomokis transaction Manager + Atomikos connection pooling 
  • Easy configurations with Spring
  • JTA implementation comes with connection Pooling & Datasource (no need of seperate JCA)
  • Does support synchronization
  • Does not support last resource optimization
2. Jboss transaction Manager

      Jboss does not come with default connection pool  or JCA to be used in Standalone mode. Hence it is ideal with server liek Jboss and not in standalone mode
       Issues 
   1. Tried Jboss TM + DBCl Connection pool(XA) as suggested in  - http://lafernando.com/2011/01/05/xa-transactions-with-apache-dbcp/
   Faced issues were in connections got exhasted and where not returned to the pool
  2. Then tried to replace DBCP with Tomcat jdbc pool - which is the advanced version of dbcp overcoming its drawbacks
   Even though jdbc pool claims to have XA support , did not find much info about it in the net. When I tried the datasource did not seem to take part in the transaction.
 So the optiosn for JCA where 
Both these did not have any great documentation for use in standalone environment.
Based on all the above we will switch back to Atomikos  because
  1. It has Support
  2. Good documentation/ examples
  3. Seems to be widely used

Tuesday, May 22, 2012

Different Serialization - Java Serialization, Jboss Serilaization & Externalization


Hi I have just compared 3 serialization strategies - only in terms of payload data and here are the results entitiy includes - Few Longs, Strings, BigDecimal, Dates , Enums etc Default Java Serialization
 @Test
 public void testJavaSerialization() throws IOException, ClassNotFoundException {
        Trade trade = new BuyTrade();
        trade.setOid(128245);
        trade.setVersion(10);
        
        trade.setOrderId(13212);
        trade.setProductId(876);
        trade.setAccountId(1234L);
        
        trade.setDateMatched(org.joda.time.DateTime.now());
        
        trade.setPrice(new BigDecimal("213.23"));
        trade.setVolume(10);
        trade.setState(TradeState.PENDING);
        trade.setOpenVolume(10);
        trade.setType(TradeType.SETTLEMENT);
 
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream oout = new ObjectOutputStream(bout);
        oout.writeObject(trade);
        byte[] bytes = bout.toByteArray();
        System.out.println("Java Serialization :" + bytes.length);
        
        Trade deSerializedTrade = null;
        
        //deserialze
        ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
        ObjectInputStream out = new ObjectInputStream(bin);
        deSerializedTrade = (Trade) out.readObject();
        
   
 }

Default Java Serialization - 1127 bytes Jboss Serialization
 @Test
 public void testJbossSerialization() throws IOException, ClassNotFoundException {
        Trade trade = new BuyTrade();
        trade.setOid(128245);
        trade.setVersion(10);
        
        trade.setOrderId(13212);
        trade.setProductId(876);
        trade.setAccountId(1234L);
        
        trade.setDateMatched(org.joda.time.DateTime.now());        
        trade.setPrice(new BigDecimal("213.23"));
        trade.setVolume(10);
        trade.setState(TradeState.PENDING);
        trade.setOpenVolume(10);
        trade.setType(TradeType.SETTLEMENT);
 
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        JBossObjectOutputStream oout = new JBossObjectOutputStream(bout);
        oout.writeObject(trade);
        byte[] bytes = bout.toByteArray();
        System.out.println("JBoss Serialization :" + bytes.length);
        
        Trade deSerializedTrade = null;
        
        //deserialze
        ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
        JBossObjectInputStream out = new JBossObjectInputStream(bin);
        deSerializedTrade = (Trade) out.readObject();
        
    }

Jboss Serialization – 1125 bytes Externalization
 @Test
 public void testExternalizableSerialization() throws IOException, ClassNotFoundException {
        ExternalizedTrade trade = new ExternalizedTrade();
        trade.setOid(128245);
        trade.setVersion(10);
        trade.setWritable(false);
        
        trade.setOrderId(13212);
        trade.setProductId(876);
        trade.setAccountId(1234L);
        
        trade.setDateMatched(org.joda.time.DateTime.now());
        trade.setPrice(new BigDecimal("213.23"));
        trade.setVolume(10);
        trade.setState(TradeState.PENDING);
        trade.setOpenVolume(10);
        trade.setType(TradeType.SETTLEMENT);
 
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream oout = new ObjectOutputStream(bout);
        oout.writeObject(trade);
        byte[] bytes = bout.toByteArray();
        System.out.println("Externalizable Serialization :" + bytes.length);
        
        //deserialze
        Trade deSerializedTrade = null;
        ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
        ObjectInputStream out = new ObjectInputStream(bin);
        deSerializedTrade = (ExternalizedTrade) out.readObject();
  
 }


 @Override
 public void readExternal(ObjectInput input) throws IOException,
   ClassNotFoundException {
  setBias(OrderBias.lookupOrderBiasById((new Long(input.readByte()))));

  setOid(input.readLong());
  setVersion((new Long(input.readInt())));
  setWritable(input.readBoolean());
  
  setOrderId(input.readLong());
  setProductId((new Long(input.readInt())));
  setAccountId(input.readLong());
  setDateMatched((org.joda.time.DateTime)input.readObject());
  setPrice(new BigDecimal((String)input.readObject()));
  setVolume((new Long(input.readInt())));
  setState(TradeState.lookupTradeStateById((new Long(input.readByte()))));
  setOpenVolume((new Long(input.readInt())));
  setType(TradeType.lookupTradeStateById((new Long(input.readByte()))));
  
 }
 
 @Override
 public void writeExternal(ObjectOutput output) throws IOException {
  output.writeByte(((Long)getBias().getId()).intValue());
  
  output.writeLong(getOid());
  output.writeInt(((Long)getVersion()).intValue());
  output.writeBoolean(isWritable());

  output.writeLong(getOrderId());
  output.writeInt(((Long)getProductId()).intValue());
  output.writeLong(getAccountId());
  output.writeObject(getDateMatched());
  output.writeObject(getPrice().toString());
  output.writeInt(((Long)getVolume()).intValue());
  output.writeByte(((Long)getState().getId()).intValue());
  output.writeInt(((Long)getOpenVolume()).intValue());
  output.writeByte(((Long)getType().getId()).intValue());
 }

 
Externalizable - 999 bytes

  Notes :

1. BigDecimal - when serialized as Strings has 60% less payload when compared to bytes.

 2. Date - Calendar is a very heavy to serialize when compared to its counterpart Joda Date time

 3. Enums - can be write efficiently serialized. Ref :

Wednesday, May 16, 2012

Spring Configurations for JTA Transaction - XA datasource (Mysql) + Jboss Transaction manager(Arjuna) + Spring Transaction annotations + DBCP Connection pooling

Mysql complaint mysql xa datasource and Atomikos connection pooling

     
   
   
   
     
  
   
        
        
    

    
     
     
    
    
    
        
        
        
        
        false
        true
    

    
    
        
  
    


Jboss transaction manager settings

 
 


 
 

 


 
  
   
  
  
   
  
 

Maven dependencies for dbcp and jboss transaction manager

              4.16.4.Final

  
    commons-dbcp
    commons-dbcp
    1.4
  

  
   org.jboss.jbossts
   jbossjta
   ${jboss.jta.version}
  




Friday, May 11, 2012

Spring Configuratiosn for JTA Transaction - XA datasource (Mysql) + Atomikos Transaction manager + Spring Transaction annotations





Mysql complaint mysql xa datasource  and Atomikos connection pooling



 <bean id="dataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean"
  init-method="init" destroy-method="close">
  <property name="uniqueResourceName" value="MAIN-ATOMIKOS-CONNECTION" />
  <property name="poolSize" value="${initialSize}" />
  <property name="xaDataSourceClassName"
   value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource" />
  <property name="xaProperties" ref="databaseProperties" />
  <property name="testQuery" value="select 1" />
 </bean>




database.properties


<util:properties id="databaseProperties"
  location="classpath:database.properties" />



url=jdbc\:mysql\://localhost\:3306/<DBNAME>
user=root
password=
autoReconnect=true
autoReconnectForConnectionPools=true
autoReconnectForPools=true
pinGlobalTxToPhysicalConnection=true


Transaction specific Config

Following settings are for enabling transactions

<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" 
  init-method="init" destroy-method="close"> 
           <property name="forceShutdown"> <value>true</value> </property> 
</bean>

<bean id="atomikosUserTransaction" 
  class="com.atomikos.icatch.jta.UserTransactionImp">
            <property name="transactionTimeout" 
  value="300"/> 
</bean> 

<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> 
  <property name="transactionManager"> <ref bean="atomikosTransactionManager" 
  /> </property> 
              <property name="userTransaction"> <ref bean="atomikosUserTransaction" 
  /> </property> 
</bean> 




Just adding spring Spring annotation - will now enable transaction on required methods.


Wednesday, March 21, 2012

Finding java thread which takes highest CPU

1 .Get the process id of java process

ps -aefww

2. Get all threads and CPU it consumes

ps -eLo pid,lwp,nlwp,ruser,pcpu,stime,etime,args|grep PROCESS ID

Convert llwp from decimal to hex (so 8245 would be 2035)

3. Take thread dump of java process

now open the thread dump with text editor and search for 2035, you will find something similar:
"TP-Processor234786" daemon prio=10 tid=0x00002aaad8024800 nid=0x2035 runnable [0x00002aaadef29000]
java.lang.Thread.State: RUNNABLE
at java.util.HashMap.get(HashMap.java:303)
at ......


Ref :http://javadrama.blogspot.co.uk/2012/02/why-is-java-eating-my-cpu.html

Friday, February 4, 2011

Spring AOP - Changing target of a Proxy at runtime

I had a pretty strange usecase where i wanted to change the target object of the proxy and runtime. Spring makes it so simple to use.

My usecase was as follows



ApplicationContext ctx = new ClassPathXmlApplicationContext(
"classpath:META-INF/spring/aop-poc-module-context.xml");
AccountDAO accountDao = (AccountDAO) ctx.getBean("accountDao");

IAccount account = accountDao.getById(123);

System.out.println("account" + account);

account.setName("sudheer");

System.out.println("account" + account);



Is a property is change on the entity , i want to change the entity object itself , that is , in the above use two sysouts will print different objects.

The use case arose because i was using a cache(infinispan) which did not allow modifying POJOs outside a transaction scope.

I did achieve the same using the follwing



public class AccountDAO {

private Advisor advisor;

//This is get methods of the accountDao

public IAccount getById(long id) {
//creating new account - to mock database behavior
IAccount a = new Account(369, "suji");
//Using spring factory
ProxyFactory pf = new ProxyFactory();
pf.setExposeProxy(true);
pf.addInterface(IAccount.class);
//Using by own Target source to change the Target
pf.setTargetSource(new SwappableTargetSource(a));
//advisor which holds the advice and pointcut
pf.addAdvisor(advisor);
return (IAccount) pf.getProxy();
}

public void setAdvisor(Advisor advisor) {
this.advisor = advisor;
}

}



My advice class



public class SwappableBeforeAdvice implements MethodBeforeAdvice {

@Override
public void before(Method method, Object[] args, Object target)
throws Throwable {
System.out.println("Before advice called");

if (!((IAccount) target).isWritable()) {

//Changing the target source based on specific business condition
((SwappableTargetSource) ((Advised) AopContext.currentProxy())
.getTargetSource()).swap(new Account(56, "dan"));
}

}
}



My custom target source



public class SwappableTargetSource implements TargetSource {

private Object target;

public SwappableTargetSource(Object initialTarget) {
this.target = initialTarget;
}

public synchronized Class<?> getTargetClass() {
return this.target.getClass();
}

public final boolean isStatic() {
return false;
}

public synchronized Object getTarget() {
return this.target;
}

public void releaseTarget(Object target) {
// nothing to do
}

public synchronized void swap(Object newTarget)
throws IllegalArgumentException {
this.target = newTarget;
}

@Override
public boolean equals(Object other) {
return (this == other || (other instanceof SwappableTargetSource && this.target
.equals(((SwappableTargetSource) other).target)));
}

@Override
public int hashCode() {
return SwappableTargetSource.class.hashCode();
}

@Override
public String toString() {
return "SwappableTargetSource for target: " + this.target;
}

}



These are the spring xml configuration.



<bean id="accountDao" class="com.test.dao.account.AccountDAO">
<property name="advisor" ref="settersAdvisor" />
</bean>

<bean id="swapableBeforeAdvice" class="com.test.framework.SwappableBeforeAdvice"/>



This is the advice which advise all setter methods on the bean



<bean id="settersAdvisor"
class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice">
<ref local="swapableBeforeAdvice" />
</property>
<property name="patterns">
<list>
<value>.*set.*</value>
</list>
</property>
</bean>



Thanks to this post in spring forum which helped me do this.

http://forum.springsource.org/showthread.php?t=102784

Unit test framework with Liquibase+HsqlDb+Spring transactions

When looking at options for testing DAO classes I came up with a framework using the following

1. Liquibase - For maintaing data/schema scripts

2. HSQLDB - Inmemory database for test cases

3. Spring transactions - For maintaining clean state between two test cases which make DB updates i .e all data changes made by the test cases will be rolled back by the end of the test case.


I am using spring beans to initialize all the above. I will explain each of them in detail.

1. Initializing the HSQLDB



<context:property-placeholder
location="classpath*:tspex-test-inmemorydatabase.properties" />

<bean id="hsqlDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${database.driverClassName}">
<property name="url" value="${database.url}">
<property name="username" value="${database.username}">
<!-- <property name="password" value="${jdbc.password}"> -->
</bean>



All the values will be picked up from the file mentioned in the classpath.

2. Setting up Liquibase

I am using the following method to initialize Liquibase



public class TestFramework {

private DataSource dataSource;

public void initializeLiquiBase(String changeLogFile) throws Exception {
Connection conn = dataSource.getConnection();
Liquibase liquibase = new Liquibase(changeLogFile,
new ClassLoaderResourceAccessor(), new HsqlConnection(conn));
// Uncomment the following line when testing with mysql database
/*
* Liquibase liquibase = new Liquibase(changeLogFile, new
* ClassLoaderResourceAccessor(), new JdbcConnection(conn));
*/

liquibase.update("");
conn.close();
}

public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}

}



Corresponding spring configuration.



<bean id="testFramework" class="com.mycompany.framework.unittest.TestFramework">
<property name="dataSource" ref="hsqlDataSource">
</bean>



The changeLogFile will be provided by the user of the frame work , which i will explain shortly.


3. Setting up Spring transactions.



<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="hsqlDataSource">
</bean>

<tx:annotation-driven manager="transactionManager">



These are the only classes/configuration present in my framework

The maven dependencies required are as follows



<dependency>
<groupid>org.hsqldb</groupid>
<artifactid>hsqldb</artifactid>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.liquibase</groupid>
<artifactid>liquibase-core</artifactid>
<version>2.0.0</version>
</dependency>
<dependency>
<groupid>org.liquibase</groupid>
<artifactid>liquibase-plugin</artifactid>
<version>1.9.5.0</version>
</dependency>
<dependency>
<groupid>junit</groupid>
<artifactid>junit</artifactid>
<version>4.7</version>
</dependency>



Now let me explain how the framework will be used by the classes testing the framework


A typical test class for DAO will be as follows



@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
"classpath*:/META-INF/spring/unit-test-framework-module-context.xml",
"classpath*:/META-INF/spring/test-spring-jdbc-module-context.xml" })
public class TestAccountDAOSpringJdbc {

@Autowired
private TestFramework testFramework;

@Autowired
private AccountDAOSpringJdbc accountDao;

@Test
public void setUpBeforeClass() throws Exception {
System.out.println("Setup before class called");
testFramework.initializeLiquiBase("accounts-data-changelog-1.0.xml");


@Test
@Transactional
public void testSaveUpdate() throws Exception {
// Create a new Account
Account account = accountDao.get(1);
account.setUsername("newaccount");
account.setTitle("Mr");

........


}



The important thing to note here are

1. Initializing the framework beans - which contains HSQLDB and spring transaction initialization.

2. Initializing the test framework with liquibase scripts

This ensure that the database tables are created and test data is inserted before test cases run.

Ref: http://www.liquibase.org/

3. Using @Transactional annotation before test cases which updates the Database . This ensures that test cases do not commit anything into DB and all test cases can be independent of each other.

With some infrastructure setup like this , writing test cases for DAO become very easy.

Friday, January 21, 2011

Bamboo

Bamboo is another available tool for setting Continuous Integration in your environment. Its one of the simplest tools i have come across for building a continuous integration system.

http://www.atlassian.com/software/bamboo/

The website shows a 10 minute tutorial which helps in setting up and starting the continuous integration server. The configuration options with this tool are very simple and helps in setting up the environment through the user interface available in this tool.

It has easy integration with build tools like Maven, Ant etc.

Maven

I have been using ant for a pretty long time and i was very comfortable with the flexibility it gives , until i started using Maven. Its almost been a month since i have started using maven , and i feel i will never go back to ant.

Maven works on the principle on "Convention over Configuration" .

Basic convention is each module builds a single artifact and there is a pom file associated with each module which describes all the dependencies required by the module and the properties of the module. The pom file when run can help you do a lot of things like

Compile the code.
Build the Jar
Run the test cases.
Build Java Docs ...etc and many more

Each of the above tasks belong to a particular phase in the Maven build cycle. The best things to use Maven is with a IDE like Eclipse or STS which has complete support for maven.

After i thought about writing the basics of Maven , i came across this blog from spring source which in details explains about the basics of Maven which should be a good starting point.

http://blog.springsource.com/2011/01/17/green-beans-getting-started-with-maven-and-spring/

Maven comes in with easy integration for build tools like Bamboo, Hudson and Cruisecontrol.

Once you start using Maven managing the modules. its version and its dependencies becomes a very simple task.

Wednesday, November 3, 2010

Spring Bean Life Cycle Phases

I want to demonstrate the bean Life Cycle with a help of a simple Example.

Phase 1. BeanPostProcessor: Bean definitions are changes here.

[Example : Property file replacement as property values.]

Phase 2: Object Creation Phase

Phase 3 :Setting Required Dependencies

Phase 4: Initialization Phase


There is a separate phase called BeanPostProcessor phase in which there the bean itself can be changes.

The org.springframework.beans.factory.config.BeanPostProcessor interface consists of exactly two callback methods. When such a class is registered as a post-processor with the container (see below for how this registration is effected), for each bean instance that is created by the container, the post-processor will get a callback from the container both before any container initialization methods (such as afterPropertiesSet and any declared init method) are called, and also afterwards. The post-processor is free to do what it wishes with the bean instance, including ignoring the callback completely.

Spring uses runtime AOP and hence creates proxy based implementation using this phase.
Since AOP auto-proxying is implemented as a BeanPostProcessor itself, no BeanPostProcessors
or directly referenced beans are eligible for auto-proxying (and thus will not have aspects 'woven' into them.

In my sample example i will not be talking about BeanFactoryPostProcessorPhase or BeanPostProcessor instaed will be concentrating on the phases.

Consider teh following three simple classes.



public class Bean1{

private Bean2 bean2;

private Bean3 bean3;

public void setBean3(Bean3 bean3) {
this.bean3 = bean3;
System.out.println("Setter Called For bean3");
}


public Bean1(Bean2 bean2) {
super();
this.bean2 = bean2;
System.out.println("Bean 1 constructor called");
}

public void init() {
System.out.println("Init of bean1 method called");
}

}






public class Bean2 {

private Bean1 bean1;

public Bean2() {
super();
System.out.println("Bean2 constructior Called");
}

public void setBean1(Bean1 bean1) {
this.bean1 = bean1;
System.out.println("Setter Called");
}

public void init() {
System.out.println("Init of bean2 method called");
}

}






public class Bean3 {

public Bean3() {
super();
System.out.println("Construictor Called for Bean3");
}

private Bean1 bean1;

public void setBean1(Bean1 bean1) {
this.bean1 = bean1;
System.out.println("Setter for Bean1 Called in Bean3");
}

public void init() {
System.out.println("Init Called For Bean3");
}

}




The spring xml will be as follows



<bean id="bean1" class="com.test.Bean1" init-method="init">
<constructor-arg ref="bean2"></constructor-arg>
<property name="bean3" ref="bean3"></property>
</bean>

<bean id="bean2" class="com.test.Bean2" init-method="init">
</bean>

<bean id="bean3" class="com.test.Bean3" init-method="init">
<property name="bean1" ref="bean1"></property>
</bean>




OutPut :

Bean2 constructior Called
Init of bean2 method called
Bean 1 constructor called
Construictor Called for Bean3
Setter for Bean1 Called in Bean3
Init Called For Bean3
Setter Called For bean3
Init of bean1 method called

Let me explain how this workz

Phase 2: Object Creation Phase
Phase 3: Initialization Phase
Phase 4: Setting Required Dependencies


bean1 : Phase2(started) - Tries to create object.Since the constructor requires bean2 goes to beans 2

bean2 : Phase2(started->completed) - Creates teh object(Hence sysout from constructor)
bean2 : Phase3(started->completed) - Nothing to be done as no property setters are present
bean2 : Phase4(started->completed) - Calls init method(As there are no property values to be Set)

bean1 : Phase2(completed) - Since beans 2 is ready this phase will complete(constructor sysout printed)
bean2 : Phase3(started) - Checks for dependency and finds bean3

bean3 : Phase2(started->completed) - Creates teh object(Hence sysout from constructor)
bean3 : Phase3(started->completed) - Sets the dependencies. [******** beans 3's init is called b4 bean1's init]
bean3 : Phase4(started->completed) - Init method called.

bean1 : Phase3(started->completed) - Setters called
bean1 : Phase4(started->completed) - Init Method called.


Hence all the beans go through these individual life cycle methods.

The following is the ordering for initialization methods based on the approach followed for initializing:
[All these are part of Phase4 above]
• Methods annotated with @PostConstruct
• afterPropertiesSet() as defined by the InitializingBean callback interface
• A custom configured init() method


In all the cases spring tries to ensure that before dependencies(beans) are set , the dependency(bean) is properly initialized.(dependency set and init called). {**** -Not always true for simple property injection - i. e before bean is injected its(injected bean) init may not have been called }

This is strict for Constructor injection.[In the above case if we try to modify the bean definition for bean 3 as follows]

<bean id="bean2" class="com.test.Bean2" init-method="init">
<property name="bean1" ref="bean1"></property>
</bean>


We get the following Exception

Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'bean1': Requested bean is currently in creation: Is there an unresolvable circular reference?


This is because bean1's constructor depends on bean2. and bean2 has a setter which is bean1. Bean2 just after completing phase 2(object creation will not be injected into constructor , will wait for all phases to complete)

***** - But this is not the case with simple property injected.

Ex : Bean1 and Bean 2 injected visa versa will work fine.

 
Free Domain Names @ .co.nr!