tag:blogger.com,1999:blog-89245474656776480292024-02-07T16:19:26.552-08:00Tech TalkSudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.comBlogger147125tag:blogger.com,1999:blog-8924547465677648029.post-29707883884728935562012-06-12T03:41:00.001-07:002012-06-22T02:15:24.659-07:00Difference between XA resource register && Synchronization Listener && Last resource Gammit<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript">
</script>
<br />
<b><u>Transaction synchronization</u></b><br />
<br />
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:<br />
<br />
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.<br />
<br />
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.<br />
<br />
<b><u>Logs With Synchronization</u></b><br />
<b><u><br /></u></b><br />
(One mysql Xa resource and rest infinispan caches register as synchronization)<br />
<br />
<pre class="brush: html"> 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
</pre>
<b><u>With XA Resource
</u></b><br />
(Mysql and Infinispan caches as XA resources)<br />
<br />
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.<br />
<br />
<b><u><br /></u></b><br />
<pre class="brush: html"> 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
</pre>
<br />
<br />
<b><u>Last Resource Commit Optimization (LRCO)</u></b><br />
<br />
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.<br />
<br />
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 <local-tx-datasource> 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.</local-tx-datasource><br />
<br />
<br />
Ref : http://docs.redhat.com/docs<br />
<br />
<br /></div>Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-39326036215342771652012-06-07T02:22:00.002-07:002012-06-07T02:31:57.451-07:00JTA Transaction Manager(XA) - Analysis<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<u><strong>Requirements</strong></u></div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
We needs JTA complaint XA transaction manager since we have multiple resources</div>
<ul style="text-align: left;">
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Database - Mysql</li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Cache - Infinispan</li>
</ul>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
Both of these resources support XA - JTA transactions. - Mysql through <strong>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</strong>.</div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<u><strong>Alternatives for transaction manager </strong></u></div>
<ul style="text-align: left;">
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Atomikos - <a class="external-link" href="http://www.atomikos.com/" rel="nofollow" style="color: #003366; margin-bottom: 0px; margin-top: 0px; outline: none;">http://www.atomikos.com/</a></li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Jboss TM - <a class="external-link" href="http://www.jboss.org/jbosstm" rel="nofollow" style="color: #003366; margin-bottom: 0px; margin-top: 0px; outline: none;">http://www.jboss.org/jbosstm</a></li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Bitronix </li>
</ul>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
We also need to choose a <u><strong>connection pool framework</strong></u> for database which is XA complaint. Hence options</div>
<ul style="text-align: left;">
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Atomikos connection pooling - <a class="external-link" href="http://www.atomikos.com/" rel="nofollow" style="color: #003366; margin-bottom: 0px; margin-top: 0px; outline: none;">http://www.atomikos.com/</a></li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">DBCP Connection Pooling - <a class="external-link" href="http://commons.apache.org/dbcp/" rel="nofollow" style="color: #003366; margin-bottom: 0px; margin-top: 0px; outline: none;">http://commons.apache.org/dbcp/</a></li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Tomcat jdbc pool - <a class="external-link" href="http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html" rel="nofollow" style="color: #003366; margin-bottom: 0px; margin-top: 0px; outline: none;">http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html</a></li>
</ul>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<u><strong>Picking the right combination</strong></u></div>
<ol style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; list-style-position: outside; margin-bottom: 10px; margin-left: 0px; margin-top: 0px; padding-left: 3em; padding-top: 0px;">
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;"><strong style="margin-bottom: 0px; margin-top: 0px;">Atomokis transaction Manager + Atomikos connection pooling </strong></li>
</ol>
<ul style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; list-style-position: outside; margin-bottom: 10px; margin-left: 0px; margin-top: 0px; padding-left: 3em; padding-top: 0px;">
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Easy configurations with Spring</li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">JTA implementation comes with connection Pooling & Datasource (no need of seperate JCA)</li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Does support synchronization</li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Does not support last resource optimization</li>
</ul>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<strong>2. Jboss transaction Manager</strong></div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<strong><br /></strong> 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</div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<strong>Issues </strong></div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<strong> 1. </strong>Tried <strong>Jboss TM + DBCl Connection pool(XA)</strong> as suggested in - <a class="external-link" href="http://lafernando.com/2011/01/05/xa-transactions-with-apache-dbcp/" rel="nofollow" style="color: #003366; outline: none;">http://lafernando.com/2011/01/05/xa-transactions-with-apache-dbcp/</a></div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
Faced issues were in connections got exhasted and where not returned to the pool</div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
2. Then tried to replace DBCP with T<strong>omcat jdbc pool</strong> - which is the advanced version of dbcp overcoming its drawbacks</div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
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.</div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
The missing piece was the <strong>JCA - <a class="external-link" href="http://jbossts.blogspot.co.uk/2012/01/connecting-dots.html" rel="nofollow" style="color: #003366; outline: none;">http://jbossts.blogspot.co.uk/2012/01/connecting-dots.html</a></strong></div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<strong> So the optiosn for JCA where </strong></div>
<ul style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; list-style-position: outside; margin-bottom: 10px; margin-left: 0px; margin-top: 0px; padding-left: 3em; padding-top: 0px;">
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;"> Jboss TransactionalDriver (Not suggested for production use) -
<a href="http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html?page=1">http://www.javaworld.com/javaworld/jw-04-2007/jw-04-xa.html?page=1</a></li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;"> IronJacamar - <a class="external-link" href="http://www.jboss.org/ironjacamar" rel="nofollow" style="color: #003366; margin-bottom: 0px; margin-top: 0px; outline: none;">http://www.jboss.org/ironjacamar</a></li>
</ul>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
Both these did not have any great documentation for use in standalone environment.</div>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
Based on all the above we will switch back to Atomikos because</div>
<ol style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; list-style-position: outside; margin-bottom: 10px; margin-left: 0px; margin-top: 0px; padding-left: 3em; padding-top: 0px;">
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">It has Support</li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Good documentation/ examples</li>
<li style="font-size: 10pt; line-height: 13pt; margin: 0px; padding: 0px;">Seems to be widely used</li>
</ol>
<div style="background-color: white; font-family: Arial, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 17px; margin-bottom: 10px; padding: 0px;">
<br /></div>
</div>Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-51693915007650064152012-05-22T02:46:00.001-07:002012-05-22T02:47:06.915-07:00Different Serialization - Java Serialization, Jboss Serilaization & Externalization<div dir="ltr" style="text-align: left;" trbidi="on">
<script src="http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js" type="text/javascript">
</script>
<br />
<div dir="ltr" style="text-align: left;" trbidi="on">
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
<b>Default Java Serialization</b>
<br />
<pre class="brush: html"> @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();
}
</pre>
<b>Default Java Serialization - 1127 bytes</b>
<b>Jboss Serialization </b>
<br />
<pre class="brush: html"> @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();
}
</pre>
<b>Jboss Serialization – 1125 bytes</b>
<b>Externalization</b>
<br />
<pre class="brush: html"> @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());
}
</pre>
<b>Externalizable - 999 bytes</b><br />
<br />
<b>Notes :</b><br />
<br />
1. BigDecimal - when serialized as Strings has 60% less payload when compared to bytes.<br />
<br />
2. Date - Calendar is a very heavy to serialize when compared to its counterpart Joda Date time<br />
<br />
3. Enums - can be write efficiently serialized.
Ref :
</div>
</div>Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-4790107010557239802012-05-16T02:19:00.000-07:002012-05-16T02:21:41.971-07:00Spring Configurations for JTA Transaction - XA datasource (Mysql) + Jboss Transaction manager(Arjuna) + Spring Transaction annotations + DBCP Connection pooling<head>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script>
</head>
<div dir="ltr" style="text-align: left;" trbidi="on">
Mysql complaint mysql xa datasource and Atomikos connection pooling
<pre class="brush: html">
<bean id="mysqlXADataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<property name="user" value="${user}" />
<property name="password" value="${password}"/>
<property name="url" value="${url}"/>
</bean>
<bean id="dsXAConnectionFactory" class="org.apache.commons.dbcp.managed.DataSourceXAConnectionFactory">
<constructor-arg><ref bean="jbossTransactionManager"/></constructor-arg>
<constructor-arg><ref bean="mysqlXADataSource"/></constructor-arg>
</bean>
<bean id="pool" class="org.apache.commons.pool.impl.GenericObjectPool">
<property name="maxActive" value="${maxActive}" />
<property name="minIdle" value="${initialSize}" />
</bean>
<bean id="poolableConnectionFactory" class="org.apache.commons.dbcp.PoolableConnectionFactory">
<constructor-arg index="0"><ref bean="dsXAConnectionFactory"/></constructor-arg>
<constructor-arg index="1"><ref bean="pool"/></constructor-arg>
<constructor-arg index="2"><null/></constructor-arg>
<constructor-arg index="3"><null/></constructor-arg>
<constructor-arg index="4"><value>false</value></constructor-arg>
<constructor-arg index="5"><value>true</value></constructor-arg>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.managed.ManagedDataSource" depends-on="poolableConnectionFactory">
<constructor-arg index="0"><ref bean="pool"/></constructor-arg>
<constructor-arg index="1" value="#{dsXAConnectionFactory.getTransactionRegistry()}"/>
</bean>
</pre>
Jboss transaction manager settings
<pre class="brush: html">
<!-- Following settings are for enabling transactions -->
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="jbossTransactionManager"
class="com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple">
</bean>
<bean id="jbossUserTransaction"
class="com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple" />
<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager">
<ref bean="jbossTransactionManager"></ref>
</property>
<property name="userTransaction">
<ref bean="jbossUserTransaction" />
</property>
</bean>
</pre>
Maven dependencies for dbcp and jboss transaction manager
<pre class="brush: html">
<jboss.jta.version>4.16.4.Final</jboss.jta.version>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.jboss.jbossts</groupId>
<artifactId>jbossjta</artifactId>
<version>${jboss.jta.version}</version>
</dependency>
</pre>
<br /></div>Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-32057804553850643512012-05-11T07:19:00.001-07:002012-05-11T07:21:55.818-07:00Spring Configuratiosn for JTA Transaction - XA datasource (Mysql) + Atomikos Transaction manager + Spring Transaction annotations<head>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script>
</head>
<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<br />
<br />
<br />
Mysql complaint mysql xa datasource and Atomikos connection pooling<br />
<br />
<br />
<pre class="brush: html">
<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>
</pre>
<br />
<br />
database.properties<br />
<br />
<br />
<pre class="brush: html">
<util:properties id="databaseProperties"
location="classpath:database.properties" />
</pre>
<br />
<br />
<br />
<pre class="brush: html">
url=jdbc\:mysql\://localhost\:3306/<DBNAME><br />
user=root<br />
password=<br />
autoReconnect=true<br />
autoReconnectForConnectionPools=true<br />
autoReconnectForPools=true<br />
pinGlobalTxToPhysicalConnection=true<br />
</pre>
<br />
<br />
Transaction specific Config<br />
<br />
Following settings are for enabling transactions<br />
<pre class="brush: html">
<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>
</pre>
<br />
<br />
Just adding spring Spring annotation - will now enable transaction on required methods.<br />
<br />
<br />
</div>Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-31726048423759068832012-03-21T08:16:00.002-07:002012-03-21T08:19:41.462-07:00Finding java thread which takes highest CPU1 .Get the process id of java process<br /><br />ps -aefww<br /><br />2. Get all threads and CPU it consumes<br /><br />ps -eLo pid,lwp,nlwp,ruser,pcpu,stime,etime,args|grep PROCESS ID <br /><br />Convert llwp from decimal to hex (so 8245 would be 2035)<br /><br />3. Take thread dump of java process<br /><br /> now open the thread dump with text editor and search for 2035, you will find something similar:<br />"TP-Processor234786" daemon prio=10 tid=0x00002aaad8024800 nid=0x2035 runnable [0x00002aaadef29000] <br />java.lang.Thread.State: RUNNABLE<br />at java.util.HashMap.get(HashMap.java:303)<br />at ...... <br /><br /><br />Ref :http://javadrama.blogspot.co.uk/2012/02/why-is-java-eating-my-cpu.htmlSudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-40677243234779761052011-02-04T12:55:00.000-08:002011-02-04T13:23:25.134-08:00Spring AOP - Changing target of a Proxy at runtimeI 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.<br /><br />My usecase was as follows<br /><br /><pre class="brush: html"><br /><br /> ApplicationContext ctx = new ClassPathXmlApplicationContext(<br /> "classpath:META-INF/spring/aop-poc-module-context.xml");<br /> AccountDAO accountDao = (AccountDAO) ctx.getBean("accountDao");<br /><br /> IAccount account = accountDao.getById(123);<br /><br /> System.out.println("account" + account);<br /><br /> account.setName("sudheer");<br /><br /> System.out.println("account" + account);<br /><br /></pre><br /><br />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.<br /><br />The use case arose because i was using a cache(infinispan) which did not allow modifying POJOs outside a transaction scope.<br /><br />I did achieve the same using the follwing<br /><br /><pre class="brush: html"><br /><br />public class AccountDAO {<br /><br /> private Advisor advisor;<br /><br /> //This is get methods of the accountDao<br /><br /> public IAccount getById(long id) {<br /> //creating new account - to mock database behavior<br /> IAccount a = new Account(369, "suji");<br /> //Using spring factory<br /> ProxyFactory pf = new ProxyFactory();<br /> pf.setExposeProxy(true);<br /> pf.addInterface(IAccount.class);<br /> //Using by own Target source to change the Target<br /> pf.setTargetSource(new SwappableTargetSource(a));<br /> //advisor which holds the advice and pointcut<br /> pf.addAdvisor(advisor);<br /> return (IAccount) pf.getProxy();<br /> }<br /><br /> public void setAdvisor(Advisor advisor) {<br /> this.advisor = advisor;<br /> }<br /><br />}<br /><br /></pre><br /><br />My advice class<br /><br /><pre class="brush: html"><br /><br />public class SwappableBeforeAdvice implements MethodBeforeAdvice {<br /><br /> @Override<br /> public void before(Method method, Object[] args, Object target)<br /> throws Throwable {<br /> System.out.println("Before advice called");<br /><br /> if (!((IAccount) target).isWritable()) {<br /><br /> //Changing the target source based on specific business condition<br /> ((SwappableTargetSource) ((Advised) AopContext.currentProxy())<br /> .getTargetSource()).swap(new Account(56, "dan"));<br /> }<br /><br /> }<br />}<br /><br /></pre><br /><br />My custom target source<br /><br /><pre class="brush: html"><br /><br />public class SwappableTargetSource implements TargetSource {<br /><br /> private Object target;<br /><br /> public SwappableTargetSource(Object initialTarget) {<br /> this.target = initialTarget;<br /> }<br /><br /> public synchronized Class<?> getTargetClass() {<br /> return this.target.getClass();<br /> }<br /><br /> public final boolean isStatic() {<br /> return false;<br /> }<br /><br /> public synchronized Object getTarget() {<br /> return this.target;<br /> }<br /><br /> public void releaseTarget(Object target) {<br /> // nothing to do<br /> }<br /><br /> public synchronized void swap(Object newTarget)<br /> throws IllegalArgumentException {<br /> this.target = newTarget;<br /> }<br /><br /> @Override<br /> public boolean equals(Object other) {<br /> return (this == other || (other instanceof SwappableTargetSource && this.target<br /> .equals(((SwappableTargetSource) other).target)));<br /> }<br /><br /> @Override<br /> public int hashCode() {<br /> return SwappableTargetSource.class.hashCode();<br /> }<br /><br /> @Override<br /> public String toString() {<br /> return "SwappableTargetSource for target: " + this.target;<br /> }<br /><br />}<br /><br /></pre><br /><br />These are the spring xml configuration.<br /><br /><pre class="brush: html"><br /><br /><bean id="accountDao" class="com.test.dao.account.AccountDAO"><br /> <property name="advisor" ref="settersAdvisor" /><br /> </bean><br /><br /> <bean id="swapableBeforeAdvice" class="com.test.framework.SwappableBeforeAdvice"/><br /><br /></pre><br /><br />This is the advice which advise all setter methods on the bean<br /><br /><pre class="brush: html"><br /><br /> <bean id="settersAdvisor"<br /> class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"><br /> <property name="advice"><br /> <ref local="swapableBeforeAdvice" /><br /> </property><br /> <property name="patterns"><br /> <list><br /> <value>.*set.*</value><br /> </list><br /> </property><br /> </bean><br /> <br /></pre><br /><br />Thanks to this post in spring forum which helped me do this.<br /><br />http://forum.springsource.org/showthread.php?t=102784Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-31904658924694526902011-02-04T11:50:00.000-08:002011-02-04T12:37:22.947-08:00Unit test framework with Liquibase+HsqlDb+Spring transactionsWhen looking at options for testing DAO classes I came up with a framework using the following<br /><br />1. Liquibase - For maintaing data/schema scripts<br /><br />2. HSQLDB - Inmemory database for test cases<br /><br />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.<br /><br /><br />I am using spring beans to initialize all the above. I will explain each of them in detail.<br /><br />1. Initializing the HSQLDB<br /><br /><pre class="brush: html"><br /><br /><context:property-placeholder<br /> location="classpath*:tspex-test-inmemorydatabase.properties" /><br /><br /> <bean id="hsqlDataSource" class="org.apache.commons.dbcp.BasicDataSource"<br /> destroy-method="close"><br /> <property name="driverClassName" value="${database.driverClassName}"><br /> <property name="url" value="${database.url}"><br /> <property name="username" value="${database.username}"><br /> <!-- <property name="password" value="${jdbc.password}"> --><br /> </bean><br /><br /></pre><br /><br />All the values will be picked up from the file mentioned in the classpath.<br /><br />2. Setting up Liquibase<br /><br />I am using the following method to initialize Liquibase<br /><br /><pre class="brush: html"><br /><br />public class TestFramework {<br /><br /> private DataSource dataSource;<br /><br /> public void initializeLiquiBase(String changeLogFile) throws Exception {<br /> Connection conn = dataSource.getConnection();<br /> Liquibase liquibase = new Liquibase(changeLogFile,<br /> new ClassLoaderResourceAccessor(), new HsqlConnection(conn));<br /> // Uncomment the following line when testing with mysql database<br /> /*<br /> * Liquibase liquibase = new Liquibase(changeLogFile, new<br /> * ClassLoaderResourceAccessor(), new JdbcConnection(conn));<br /> */<br /><br /> liquibase.update("");<br /> conn.close();<br /> }<br /><br /> public void setDataSource(DataSource dataSource) {<br /> this.dataSource = dataSource;<br /> }<br /><br />}<br /><br /></pre><br /><br />Corresponding spring configuration.<br /><br /><pre class="brush: html"><br /><br /> <bean id="testFramework" class="com.mycompany.framework.unittest.TestFramework"><br /> <property name="dataSource" ref="hsqlDataSource"><br /> </bean><br /><br /></pre><br /><br />The changeLogFile will be provided by the user of the frame work , which i will explain shortly.<br /><br /><br />3. Setting up Spring transactions.<br /><br /><pre class="brush: html"><br /><br /> <bean id="transactionManager"<br /> class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><br /> <property name="dataSource" ref="hsqlDataSource"><br /> </bean><br /><br /> <tx:annotation-driven manager="transactionManager"><br /><br /></pre><br /><br />These are the only classes/configuration present in my framework<br /><br />The maven dependencies required are as follows<br /><br /><pre class="brush: html"><br /><br /> <dependency><br /> <groupid>org.hsqldb</groupid><br /> <artifactid>hsqldb</artifactid><br /> <version>2.0.0</version><br /> <scope>test</scope><br /> </dependency> <br /> <dependency><br /> <groupid>org.liquibase</groupid><br /> <artifactid>liquibase-core</artifactid><br /> <version>2.0.0</version><br /> </dependency><br /> <dependency><br /> <groupid>org.liquibase</groupid><br /> <artifactid>liquibase-plugin</artifactid><br /> <version>1.9.5.0</version><br /> </dependency><br /> <dependency><br /> <groupid>junit</groupid><br /> <artifactid>junit</artifactid><br /> <version>4.7</version><br /> </dependency><br /><br /></pre><br /><br />Now let me explain how the framework will be used by the classes testing the framework<br /><br /><br />A typical test class for DAO will be as follows<br /><br /><pre class="brush: html"><br /><br />@RunWith(SpringJUnit4ClassRunner.class)<br />@ContextConfiguration(locations = {<br /> "classpath*:/META-INF/spring/unit-test-framework-module-context.xml",<br /> "classpath*:/META-INF/spring/test-spring-jdbc-module-context.xml" })<br />public class TestAccountDAOSpringJdbc {<br /><br /> @Autowired<br /> private TestFramework testFramework;<br /><br /> @Autowired<br /> private AccountDAOSpringJdbc accountDao;<br /><br /> @Test<br /> public void setUpBeforeClass() throws Exception {<br /> System.out.println("Setup before class called");<br /><span> testFramework.initializeLiquiBase("accounts-data-changelog-1.0.xml");</span><br /><br /><br /> @Test<br /> @Transactional<br /> public void testSaveUpdate() throws Exception {<br /> // Create a new Account<br /> Account account = accountDao.get(1);<br /> account.setUsername("newaccount");<br /> account.setTitle("Mr");<br /><br /> ........<br /><br /><br />}<br /><br /></pre><br /><br />The important thing to note here are<br /><br />1. Initializing the framework beans - which contains HSQLDB and spring transaction initialization.<br /><br />2. Initializing the test framework with liquibase scripts<br /><br />This ensure that the database tables are created and test data is inserted before test cases run.<br /><br />Ref: http://www.liquibase.org/<br /><br />3. Using <span style="font-weight: bold;">@Transactional </span>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.<br /><br />With some infrastructure setup like this , writing test cases for DAO become very easy.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-14711176071158906772011-01-21T13:28:00.001-08:002011-01-21T13:35:04.414-08:00BambooBamboo 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.<br /><br />http://www.atlassian.com/software/bamboo/<br /><br />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.<br /><br />It has easy integration with build tools like Maven, Ant etc.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-3585988988644850312011-01-21T13:12:00.000-08:002011-01-21T13:35:04.415-08:00MavenI 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.<br /><br />Maven works on the principle on "Convention over Configuration" .<br /><br />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<br /><br />Compile the code.<br />Build the Jar<br />Run the test cases.<br />Build Java Docs ...etc and many more<br /><br />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.<br /><br />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.<br /><br />http://blog.springsource.com/2011/01/17/green-beans-getting-started-with-maven-and-spring/<br /><br />Maven comes in with easy integration for build tools like Bamboo, Hudson and Cruisecontrol.<br /><br />Once you start using Maven managing the modules. its version and its dependencies becomes a very simple task.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-22330564458830615332010-11-03T11:39:00.001-07:002010-11-10T02:33:06.816-08:00Spring Bean Life Cycle PhasesI want to demonstrate the bean Life Cycle with a help of a simple Example.<br /><br /><span style="font-weight: bold;">Phase 1. BeanPostProcessor</span>: Bean definitions are changes here.<br /><br />[Example : Property file replacement as property values.]<br /><br /><span style="font-weight: bold;">Phase 2: Object Creation Phase</span><br /><br /><span style="font-weight: bold;">Phase 3 :Setting Required Dependencies</span><br /><br /><span style="font-weight: bold;">Phase 4: Initialization Phase</span><br /><br /><br />There is a separate phase called <span style="font-weight: bold;">BeanPostProcessor </span>phase in which there the bean itself can be changes.<br /><br />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.<br /><br />Spring uses runtime AOP and hence creates proxy based implementation using this phase.<br />Since AOP auto-proxying is implemented as a BeanPostProcessor itself, no BeanPostProcessors<br />or directly referenced beans are eligible for auto-proxying (and thus will not have aspects 'woven' into them.<br /><br />In my sample example i will not be talking about BeanFactoryPostProcessorPhase or BeanPostProcessor instaed will be concentrating on the phases.<br /><br />Consider teh following three simple classes.<br /><br /><pre class="brush: java"><br /><br />public class Bean1{<br /><br />private Bean2 bean2;<br /><br />private Bean3 bean3;<br /><br />public void setBean3(Bean3 bean3) {<br /> this.bean3 = bean3;<br /> System.out.println("Setter Called For bean3");<br />}<br /><br /><br />public Bean1(Bean2 bean2) {<br /> super();<br /> this.bean2 = bean2;<br /> System.out.println("Bean 1 constructor called");<br />}<br /><br />public void init() {<br /> System.out.println("Init of bean1 method called");<br />}<br /><br />}<br /><br /></pre><br /><br /><br /><pre class="brush: java"><br /><br />public class Bean2 {<br /><br />private Bean1 bean1;<br /><br />public Bean2() {<br /> super();<br /> System.out.println("Bean2 constructior Called");<br />}<br /><br />public void setBean1(Bean1 bean1) {<br /> this.bean1 = bean1;<br /> System.out.println("Setter Called");<br />}<br /><br />public void init() {<br /> System.out.println("Init of bean2 method called");<br />}<br /><br />}<br /><br /></pre><br /><br /><br /><pre class="brush: java"><br /><br />public class Bean3 {<br /><br />public Bean3() {<br /> super();<br /> System.out.println("Construictor Called for Bean3");<br />}<br /><br />private Bean1 bean1;<br /><br />public void setBean1(Bean1 bean1) {<br /> this.bean1 = bean1;<br /> System.out.println("Setter for Bean1 Called in Bean3");<br />}<br /><br />public void init() {<br /> System.out.println("Init Called For Bean3");<br />}<br /><br />}<br /><br /><br /></pre><br /><br />The spring xml will be as follows<br /><br /><pre class="brush: xml"><br /><br /> <bean id="bean1" class="com.test.Bean1" init-method="init"><br /> <constructor-arg ref="bean2"></constructor-arg><br /> <property name="bean3" ref="bean3"></property><br /></bean><br /><br /><bean id="bean2" class="com.test.Bean2" init-method="init"><br /></bean><br /><br /><bean id="bean3" class="com.test.Bean3" init-method="init"><br /> <property name="bean1" ref="bean1"></property><br /></bean><br /><br /><br /></pre><br /><br />OutPut :<br /><br />Bean2 constructior Called<br />Init of bean2 method called<br />Bean 1 constructor called<br />Construictor Called for Bean3<br />Setter for Bean1 Called in Bean3<br />Init Called For Bean3<br />Setter Called For bean3<br />Init of bean1 method called<br /><br />Let me explain how this workz<br /><br />Phase 2: Object Creation Phase<br />Phase 3: Initialization Phase<br />Phase 4: Setting Required Dependencies<br /><br /><br /><span style="font-weight: bold;">bean1 : Phase2(started) </span>- Tries to create object.Since the constructor requires bean2 goes to beans 2<br /><br /><span style="font-weight: bold;">bean2 : Phase2(started->completed)</span> - Creates teh object(Hence sysout from constructor)<br /><span style="font-weight: bold;">bean2 : Phase3(started->completed) </span>- Nothing to be done as no property setters are present<br /><span style="font-weight: bold;">bean2 : Phase4(started->completed) </span>- Calls init method(As there are no property values to be Set)<br /><br /><span style="font-weight: bold;">bean1 : Phase2(completed) </span>- Since beans 2 is ready this phase will complete(constructor sysout printed)<br /><span style="font-weight: bold;">bean2 : Phase3(started)</span> - Checks for dependency and finds bean3<br /><br /><span style="font-weight: bold;">bean3 : Phase2(started->completed)</span> - Creates teh object(Hence sysout from constructor)<br /><span style="font-weight: bold;">bean3 : Phase3(started->completed)</span> - Sets the dependencies. [******** beans 3's init is called b4 bean1's init]<br /><span style="font-weight: bold;">bean3 : Phase4(started->completed)</span> - Init method called.<br /><br /><span style="font-weight: bold;">bean1 : Phase3(started->completed)</span> - Setters called<br /><span style="font-weight: bold;">bean1 : Phase4(started->completed) </span>- Init Method called.<br /><br /><br />Hence all the beans go through these individual life cycle methods.<br /><br />The following is the ordering for initialization methods based on the approach followed for initializing:<br />[All these are part of Phase4 above]<br />• Methods annotated with @PostConstruct<br />• afterPropertiesSet() as defined by the InitializingBean callback interface<br />• A custom configured init() method<br /><br /><br />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 }<br /><br />This is strict for Constructor injection.[In the above case if we try to modify the bean definition for bean 3 as follows]<br /><br /><bean id="bean2" class="com.test.Bean2" init-method="init"><br /> <property name="bean1" ref="bean1"></property><br /></bean><br /><br /><br />We get the following Exception<br /><br />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?<br /><br /><br />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)<br /><br />***** - But this is not the case with simple property injected.<br /><br />Ex : Bean1 and Bean 2 injected visa versa will work fine.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-73344602904203003232010-10-08T01:41:00.000-07:002010-10-09T23:45:30.386-07:00Design Patterns<span style="font-weight: bold;">OO principles</span><br /><br />1. <span style="font-weight: bold;">Encapsulate what varies</span>.<br /><br />Take what varies and "encapsulate" it so it wont affect the rest of your code.<br /><br />2 . <span style="font-weight: bold;">Program to interface not an implementation</span>. [ program to super type can be abstract class also]<br /><br />Ex : Animal d = new Dog();<br /><br /> Animal g = getAnimal() - better { could be injected at run time even better , can plug new implementation without change of code}<br /><br /><br />3. <span style="font-weight: bold;">Favour composition(HAS-A) over inheritance(IS-A) </span><br /><br /><br />Advantages of Composition over Inheritance<br /><br /><br />1. <span style="font-weight: bold;">Refactoring</span> becomes very easy [No need to change super class]<br />In an inheritance relationship, super classes are often said to be "fragile," because one little change to a super class can ripple out and require changes in many other places in the application's code.<br /><br />back-end class - Super class<br /><br />front end class - Sub class<br /><br /><br />It is easier to change the interface of a back-end class (composition) than a super class (inheritance). [Only subclass functionalities which directly depends on super class can be changed , other implementation classes using teh sub class need not change.]<br /><br /><br />It is easier to change the interface of a front-end class (composition) than a subclass (inheritance). We can't add to a subclass a method with the same signature but a different return type as a method inherited from a superclass. Composition, on the other hand, allows you to change the interface of a front-end class without affecting back-end classes.<br /><br /><br />2. Composition gives high <span style="font-weight: bold;">flexibility</span>.[Change behavior at run time]<br /><br />Composition allows you to delay the creation of back-end objects until (and unless) they are needed, as well as changing the back-end objects dynamically throughout the lifetime of the front-end object.<br /><br />With inheritance, you get the image of the superclass in your subclass object image as soon as the subclass is created, and it remains part of the subclass object throughout the lifetime of the subclass.<br /><br /><br />3. The explicit method-invocation forwarding (or delegation) approach of composition will often have a performance cost as compared to inheritance's single invocation of an inherited super class method implementation [but very negligible]<br /><br /><br /><ul><li>Don't use inheritance just to get code reuse If all you really want is to reuse code and there is no is-a relationship in sight, use composition.</li></ul><br /><ul><li>Don't use inheritance just to get at polymorphism If all you really want is polymorphism, but there is no natural is-a relationship, use composition with interfaces.</li></ul><br />Ref : http://www.artima.com/designtechniques/compoinh.htmlSudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-89934876392292323072010-09-18T00:02:00.000-07:002010-09-18T00:06:25.423-07:00JavaScript/Css Basics- PresentationLinking a java script/ css presentation prepared by one of my friend . It covers right from basics.<br /><br />https://dl.dropbox.com/u/4970006/blog/static/presentations/webapps.htmlSudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-11345425056263926912010-08-09T20:56:00.000-07:002010-08-09T20:58:08.448-07:00Issues during migration of platform to OSGi1. Certain framework classes had to be part of boot delegation like Terracotta.<br /><br /> Added com.tc.* to org.osgi.framework.bootdelegation = \ in <br /><br /> /home/pg/thirdparty/springsource-dm-kernel-2.0.0.RELEASE/lib/java6-server.profile<br /><br />2.Certain jboss imports were not getting part of package imports when jars were run through bundlor<br /><br />So had to explicitly add these to bundles which required JMS(JBoss MQ) functionalities.<br /><br />org.jboss.logging,<br />org.jboss.mq.referenceable,<br />org.jnp.interfaces,<br />org.jboss.util,<br /><br /><br />3. If there is any Custom Class Loader created in the code ,special care has to be taken to ensure that you set the custom class loaders parent to Bundle Classloader.<br /><br /><br />4. Special care needs to be taken that classes loaded through custom class loader should see all its imports and exports through its parent Bundles manifest.<br /><br /><br />5. Where ever class was loaded using Class.forname() we had to change it to ensure these where done through Thread Context Classloader where classes were laoded from other bundle.<br /><br />6. Since we use jbossallclient.jar for JMS(Jboss MQ) we had issues as this was conflicting with packages in bootdelegation.<br /><br />We could either solve this using explicit imports from system bundle(bundle 0).<br /><br />a. <br /><br />BootClasspath was exporting javax.management<br /><br />Removed javax.management from jboss all client jar - Using bundlor excluded exports manifest<br /><br />b.<br /><br />Because jboss-allclient.jar also exports javax.jms which is also exported by javax.jms_1.1.0 bundle<br /><br />Ensured jbossallclient.jar imports this and doesnt export it by changing manifest.<br /><br /><br />7.Since there were multiple bundles exporting org.apache.log4j , i had to explicitly mention bundle <br />symbolic names for the imports.<br /><br />There were certain cases of cyclic dependency since it was legacy code.<br /><br />Code in one bundle was initialized(spring application context) by code in another bundle. This cyclic dependency was solved by <br />explicitly marking this imports as optional(resolution="optional").<br /><br /><br />8. Wherever Application Context was read using regular expression had to change classpath: to classpath*: to ensure that all classpath resources are read.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-80271510214130359652010-08-09T20:50:00.000-07:002010-08-09T20:55:09.704-07:00BootStrap Initialization GuideLines (For same code base to work in both OSGi and Non-OSGi environment)During the migration of the platform into OSGi we had use cases where we needed the platform to work in both OSGi and non OSGi cases until the OSGi platform had stabilized.But our mail goal was we needed the same code based and packaging to work in both OSGi and non OSGi use cases.<br /><br />We had come up with list of guidelines and conventions to achieve the same.<br /><br />One major assumption was that in a non OSGi case there has to be a single application Context as against OSGi where there is application context<br />per bundle.<br /><br /><br />1. Separate xml files for OSGi service definitions and bean definitions.<br /><br />2. Naming convention for spring xml files are as follows<br /><br /> <MODULE_NAME>-osgi-context.xml<br /> <MODULE_NAME>-bean-context.xml<br />3.Naming convention for beans to be exported as services<br /><br /> Service Exposing side<br /> <bean id="<MODULE_NAME>service" class="XXX.YYY.ZZZ"/><br /> <osgi:service ref=""<MODULE_NAME>service"" interface="bla.bla.IService"/><br /><br /> Service Reference side<br /> <osgi:ref interface=" bla.bla.IService" id="<MODULE_NAME>service"/><br /> Now this <MODULE_NAME>service can be used as regular bean.<br /> This convention will help us run the same code base both in OSGi and non OSGi cases without changing these xmls. Note that in non OSgi cases we will initialize META-INF/spring/*-bean-context.xml. This will help in unit testing so that only required xmls can be initialized.<br /><br />4. All spring bean definition files have to be in the following location - META-INF/spring/*<br /><br />5. Ensure that in NON-OSGI cases individual products/services/modules do not independently initialize the application Context.There should be a independent initialization moduel which initilialises the app context across all products(jars) in the Vm based on some naming convention followed by the products.This will help easy wiring of beans across products which in other cases are done through OSGi services.Also the common module will expose a method in for accessing the beans present in the context.<br /><br />6. Conventions have to be followed so that there are no same named beans across products as there is a single application context and objects will get overridden.<br /><br />7.Boot Strap initialized xmls with this regular expression - [*-bean-context.xml]<br /><br />[** Ensure that if any module in not following all these conventions the spring xml file has to be in any other folder than META-INF/spring ***[so that DM server doesnt initialize it ]* . *Ensure that in any case the spring xmls** are not initialized twice *[all the above guidelines are just to ensure that ] ***]<br /><br />8. Property File initialization<br /><br />Property placeholder config definitions containing files should be seperated from bean and osgi definition files and should be present in META-INF/spring folder.<br /><br />Naming convention pgconfig-<MODULE_NAME>.properties<br /><br />This will be initialized in bootstrap based on this expression in teh bootstrap propertyPlaceHolconfigurator : "classpath*:pgconfig*.properties"<br /><br />{"classpath*:META-INF/spring/bootstrapconfig.xml","classpath*:/META-INF/spring/*-bean-context.xml"};<br /><br />bootstrapconfig.xml contains --> <context:property-placeholder location="classpath*:pgconfig*.properties"/><br /><br />9.Avoid using Bundle Activator and instead use spring config (init method) for initialization as this will give us a common approach in both OSGi and Non OSGi cases.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-34994391425014373492010-08-09T20:47:00.001-07:002010-08-09T20:50:21.714-07:00OSGi Guidelines1.Interaction between non-core bundles which can be hot-deployed should be through services (Interfaces).<br /><br />2.Bundle should Import packages only for utilities, datatypes packages / classes and interfaces.<br /> <br />3.Interface and implementation should be separately bundled. The datatypes associated with service contracts can be bundled along with the interfaces.<br /><br />4.All third party jars should be converted into bundles. Avoid using "external" in Bundle-classpath.<br /><br />5.Avoid split package. Proper package structure should be followed. Two bundles should not have same package structure. We can have package structure like -.<br /><br />6.TC shared classes to be bundled into separate bundles.<br /> <br />7.Avoid static variables and blocks.<br /><br />8.Avoid Class.forname instead use Classloader.loadclass(). Class.forname may cause issues when bundle is hot deployed as initiating classloader caches the loaded class.<br /> <br />9.Classes present in separate dependent bundles should be loaded using TCCL. For example in jdbcframework all TYPE classes would be bundled with the respective bundle. These classes have to be loaded by jdbcframework bundle. Since classes present in respective bundle will not be visible to jdbcframewok bundle, so jdbcframework bundle has to use TCCL to load these classes.<br /> <br />10.Cyclic dependency should not exist between bundles.<br /> <br />11.Resource clean up - Each bundle / bean should clean up its resources like threads, sockets, cache, file handles, connections etc using its life cycle method (using "destroy" of bean or "stop" of "bundle activator")<br /> <br />12.Use the bean initialization method to initialize the properties and avoid putting initialization logic into constructor.<br /> <br />13.Native library to be loaded once. The code that is loading the native library should be part of core bundle which should not be hot deployed.<br /> <br />14.Prefer composition over inheritance.<br /> <br />15.Use AOP for common concerns - prefer compile time weaving over load-time / runtime weaving.<br /> <br />16.Use DM kernel when web container is not required.<br /> <br />17.Prefer import package over import-bundle. <br /><br />18.All In-House jars should not have resolution optional for package imports.[Just to ensure that in production enviroment dependencies are resolved at deployment time rather than run time.]<br /><br />19.All third party converted jars have resolution=optional.Else this pulled a not of other jars which were never used.<br /><br />20.All log4j imports should have bundle symbolic name for lo4j to resolve properly to log4j instead of slf4j - something like<br /><br /> org.apache.log4j.*;bundle-symbolic-name="com.springsource.org.apache.log4j"<br /><br /> This can be added as part of Bundlor template during building the jar.<br /><br />21.Manifest is generated at build time based on template(Spring Utility like Bundlor can be used for the same).Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-68592658523170729592010-05-09T01:49:00.000-07:002010-05-16T09:35:43.255-07:00Thread Context Classloader in Deserialization - ObjectInputStreamWe had uses cases, especially with OSGI where we had to use TCCL in deserialization of Object InputStream.<br /><br />Sample method<br /><br />public static Object getObject(byte[] bArr){<br /> try{<br /> ByteArrayInputStream bais = new ByteArrayInputStream(bArr);<br /> ObjectInputStream ois = new ObjectInputStream(bais);<br /> return ois.readObject();<br /> }catch(Exception err){<br /> err.printStackTrace();<br /> }<br /> return null;<br /> }<br /><br /><br /> return ois.readObject() - fails because ObjectInputStream doesnt take into consideration TCCL when deserializing.<br /><br />In OSGi we need to deserialize this using TCCL because objects being deserialized are in another bundle and framework bundle canot see these classes.<br /><br />Java has provided a way to solve this . We need to extend ObjectInputStream and overide the<br /> public Class resolveClass(ObjectStreamClass desc) method.<br /><br />[Since resolveClass class is protected method in ObjectInputStream ]<br /><br />Code<br /><br /><br />public class MyObjectInputStream extends ObjectInputStream {<br /><br /> @Override<br /> public Class resolveClass(ObjectStreamClass desc) throws IOException,<br /> ClassNotFoundException {<br /> ClassLoader currentTccl = null;<br /> try {<br /> currentTccl = Thread.currentThread().getContextClassLoader();<br /> return currentTccl.loadClass(desc.getName());<br /> } catch (Exception e) {<br /> }<br /><br /> }<br /> return super.resolveClass(desc);<br /> }<br /><br /> public MyObjectInputStream(InputStream in) throws IOException {<br /> super(in);<br /> }<br /><br />}<br /><br />Now we can use MyObjectInputStream which ensures that TCCL will have visibility to deserialize the class.<br /><br /> MyObjectInputStream ois = new MyObjectInputStream(bais);<br /> return ois.readObject();Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com2tag:blogger.com,1999:blog-8924547465677648029.post-21038654327271469092010-05-09T01:29:00.000-07:002010-05-09T01:47:52.180-07:00Using Bundlor for automated generation of Osgi manifest filesOne of the most useful utilities which helps in automated creation of manifest files. This gives all the hooks required for customization.<br /><br />A sample template file used for generation<br /><br />Bundle-Name: ${bundle.name}<br />Bundle-Description: ${bundle.description}<br />Bundle-ManifestVersion: 2<br />Bundle-SymbolicName: ${bundle.symbolic.name}<br />Bundle-Vendor: ${bundle.vendor}<br /><span style="font-weight: bold;">Import-Template</span>: org.apache.log4j.*;bundle-symbolic-name="com.springsource.org.apache.log4j", *<br />Excluded-Imports: com.sun.*,javax.xml.*,org.apache.xerces.jaxp.*,org.w3c.*,org.xml.*,sun.*,com.tc.*<br /><br /><br />Here the Import template functionality gives complete flexibility to control my imports> This ensures that all subpackages of org.apache.lo4j if imported by bundle will have bundle symbolic names attached to it.<br /><br />If there is any private package , based on some naming convention we can exclude this from being exported. Also boot delegated packages should be excluded for exporting.<br /><br />Boot delegated package exports can be avoided by passing osgi profile file to bundlor.<br />At this moment - Bundlor 1.0.0 had a Bug with this feature which is fixed in the daily snapshot version.<br />Ref : http://forum.springsource.org/showthread.php?t=87312<br /><br />Hence bundlor automates a lot of these things and there is no need for static commit of manifest files.<br /><br />This can be easily integrated with any build for the project as follows<br /><br /> <target name="bundlor.init"><br /> <taskdef resource="com/springsource/bundlor/ant/antlib.xml"<br /> uri="antlib:com.springsource.bundlor.ant"><br /> <classpath id="bundlor.classpath"><br /> <fileset dir="${bundlor.home}/dist"/><br /> <fileset dir="${bundlor.home}/lib"/><br /> </classpath><br /> </taskdef><br /> </target><br /> <br /> <br /> <bundlor:bundlor<br /> inputPath="${basedir}/xxx_jar.jar"<br /> outputPath="${basedir}/xxx_bundle.jar"<br /> manifestTemplatePath="${basedir}/${bundlor.config.dir}/xxx.mf"<br /> propertiesPath="${basedir}/${bundlor.config.dir}/xxx.properties"<br /> osgiProfilePath="${basedir}/${bundlor.home}/profile/java6-server.profile"/><br /><br />Ref: http://www.springsource.org/bundlorSudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-34580493575756151452010-05-09T01:10:00.000-07:002010-05-09T01:47:37.860-07:00Integration of Terracotta with Spring Dm serverAt this moment I am using the following version of the softwares<br /><br />Spring DM server(or DM Kernel) - 2.0.1 version<br />Terracotta- version 3.2.1<br /><br /><span style="font-weight: bold;">Steps</span><br /><br />In Dm server<br /><br />1. Modify springsource-dm-kernel-2.0.1.RELEASE\bin\dmk.sh to start with terracotta cleint.<br /><br /> Change $JAVA_HOME/bin/java to $TERRACOTTA_CLIENT_PATH/bin/dso-java.sh<br /><br />2. Change springsource-dm-kernel-2.0.1/lib/java6-server.profile to include terracotta classes in boot delegation path<br /><br />Add under org.osgi.framework.bootdelegation = \<br /> com.tc.*,\<br /> com.tcclient,\<br /> com.tcclient.*<br /><br /><span style="font-weight: bold;">Changes in Terracotta</span><br /><br />1. change tc-config.xml to have the following tims<br /><br /> <modules><br /> <module name="tim-equinox-3.5.1" version="1.1.1"/><br /> <module name="tim-ehcache-2.0" version="1.5.2"/><br /> <module name="tim-distributed-cache" version="1.3.2"/><br /> <module name="tim-concurrent-collections" version="1.3.2"/><br /> </modules><br /><br />2. Add the following app group element in tc-config.xml<br /><br /> <app-group name="osgiAppGroup"><br /> <named-classloader>Standard.system</named-classloader><br /> <named-classloader>dso-shared.0.0.0</named-classloader><br /> </app-group><br /><br /><br />Thw app group element in only required if you want to share dso classes between standalone JVM and Spring Dm server(where dso classes are laoded by bundle classlaoder).<br /><br />Also important thing to be noted is that inside a JVM all shared classes(dso's) have to be laoded by a single classloader.[Inside spring Dm server all dso classes should be a single bundle]Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-6574817388858317972010-05-08T04:45:00.000-07:002010-05-09T01:48:28.197-07:00Soft Reference /Weak Refernce /Phantom Reference / finalize()Using teh above types we get a refernce to a object which ensure that teh object can still be GCed.<br /><br />Main purpose of all the above types is to ensure that the reference is not held and hence GC can<br />collect all these objects from the heap.<br /><br />The order in which the reference - from Strong to Weak are as follows<br />Strong reference,Soft Reference ,Weak reference and Phantom Reference<br /><br />Strong Reference - are normal references which will not be garbage collected because some objects will have reference to it.<br /><br /><span style="font-weight: bold;">SoftReference -</span><br /> Having a soft Reference to a object will not stop GC on that object. By using SoftRefernce the virtual machines does not clear this references until there is shortage of memory.But this ensures that before the system crashes with OutOfMemory errors all soft references will be GC'ed.<br /><br />Hence this becomes a very good candidate for maintaing cache.Thus objects will remain in cache until there is enough memory. Once there is shortage they will be collected.<br /><br /><br /><span style="font-weight: bold;">Weak Reference </span>- Is similar to soft reference with the only difference that it will be GC'ed as soon as there are no other references . This will be very handly in most cases where there exists explicit refernce to objects which stop garbage colection.<br /><br />If Weak Reference is not used , we need to explicitly clear the contents as part of cleanup.<br /><br />WeakHashMap is one such data structure which will automatically clear references when there are not other references to objects. WeakHashMap works exactly like HashMap, except that the keys (not the values!) are referred to using weak references .If a WeakHashMap key becomes garbage, its entry is removed automatically.<br /><br /><br />Both weak and Softreference have constructors of format<br /><br />WeakReference(Object referent, ReferenceQueue q) & WeakReference(Object referent)<br />SoftReference(Object referent, ReferenceQueue q) & SoftReference(Object referent)<br /><br />where ReferenceQueue is queue which will be populated with objects(Weak/Soft references) which are GC'ed.[The objects they are pointing to will be GC'ed after which these references become dead]<br /><br />Hence we can use this ReferenceQueue info for cleanup purposes.<br /><br /><br /><span style="font-weight: bold;">Reference queues</span><br /><br />Once a WeakReference starts returning null, the object it pointed to has become garbage and the WeakReference object is pretty much useless. This generally means that some sort of cleanup is required;<br /><br />The ReferenceQueue class makes it easy to keep track of dead references. If you pass a ReferenceQueue into a weak reference's constructor, the reference object will be automatically inserted into the reference queue when the object to which it pointed becomes garbage. You can then, at some regular interval, process the ReferenceQueue and perform whatever cleanup is needed for dead references.<br /><br />The remove() method can be used to get notifications on objects Garbage Collected.<br />http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ref/ReferenceQueue.html<br /><br />To access WeakReference or SoftReference we have to use the public Object get().<br />If this reference object has been cleared, either by the program or by the garbage collector, then this method returns null.<br /><br /><br />A soft reference is exactly like a weak reference, except that it is less eager to throw away the object to which it refers. An object which is only weakly reachable (the strongest references to it are WeakReferences) will be discarded at the next garbage collection cycle, but an object which is softly reachable will generally stick around for a while<br /><br /><br /><span style="font-weight: bold;">Finalize()</span><br /><br /><br />This is Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.<br /><br />This has to be carefully used because sometime improper use of this method can get teh object back to life.<br /><br />This is also costly because garbage collection in its every traversal has to keep account of the finalize method variables and exclude it from considering as normal reference.Also until finalize method is called other objects will not be GC'ed because of its changes to come back to life. This can be solved with Phantom reference.<br /><br />Finalize() method is costly -hence phantom reference can be used for the same purpose.<br /><br /><span style="font-weight: bold;">Phantom Reference</span><br /><br />Phantom references are most often used for scheduling pre-mortem cleanup actions in a more flexible way than is possible with the Java finalization mechanism.<br /><br />In order to ensure that a reclaimable object remains so, the referent of a phantom reference may not be retrieved: The get method of a phantom reference always returns null.<br /><br />A phantom reference is quite different than either SoftReference or WeakReference. Its grip on its object is so tenuous that you can't even retrieve the object -- its get() method always returns null.<br /><br />The only use for such a reference is keeping track of when it gets enqueued into a ReferenceQueue, as at that point you know the object to which it pointed is dead and perform some cleanup.<br /><br /><span style="font-weight: bold;">Difference b/ Weak-Soft & Phantom Reference</span><br /><br />The difference is in exactly when the enqueuing happens. Weak/Soft References are enqueued as soon as the object to which they point becomes weakly reachable. This is before finalization or garbage collection has actually happened; in theory the object could even be "resurrected" by an unorthodox finalize() method, but the WeakReference would remain dead.<br /><br />PhantomReferences are enqueued only when the object is physically removed from memory, and the get() method always returns null specifically to prevent you from being able to "resurrect" an almost-dead object.<br /><br />2 Usecases with PhantomReference<br /><br />1. Only way to determine exactly when an object was removed from memory based on which some actions can be performed<br /><br />2.PhantomReferences avoid a fundamental problem with finalization: finalize() methods can "resurrect" objects by creating new strong references to them. Hence garbage collection of teh object is postponed untill finalize metdod is called.(because finaize object may<br />reconstruct the object ).With phantom reference no way the objects can be reconstructed and Gc will happen soon<br /><br /><br />Reference.<br />http://weblogs.java.net/blog/enicholas/archive/2006/05/understanding_w.html<br />http://mindprod.com/jgloss/weak.html<br />http://www.javalobby.org/forums/thread.jspa?threadID=16520&messageID=91822406&tstart=0<br />http://onjava.com/pub/a/onjava/2001/07/09/optimization.html?page=2Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-67795492700647206412010-04-13T10:32:00.000-07:002010-04-13T10:34:51.952-07:00Useful OSGi(Spring DM) utilities1.<br />Using OsgiServiceProxyFactoryBean to create proxy(equivalent to osgi:ref)<br /> <br />I had usecase where i could not use osgi:ref or osgi:list to reference a service ,because when the proxy is created it<br />creates on the generic interface given, which that particular bundle can see.<br /><br />To get away with this usecase , we created proxies using API's.<br /><br />http://static.springsource.org/osgi/...orter/support/OsgiServiceProxyFactoryBean.html<br /><br />OsgiServiceProxyFactoryBean proxy = new OsgiServiceProxyFactoryBean();<br />proxy.setBundleContext(bundle.getBundleContext());<br />proxy.setBeanClassLoader(cls.getClassLoader());<br />proxy.setInterfaces(new Class[] {cls});<br />proxy.afterPropertiesSet();<br /><br />2.<br /><br />There is a distinction between the OSGi bundle state and the state of the BundleInstallArtifact. The latter is displayed by the shell "bundle" commands.<br /><br />BundleInstallArtifact only transitions to ACTIVE when any Spring DM application context has been published in the service registry. The OSGi bundle may<br />transition to ACTIVE earlier than this as it does not take into account publication of any Spring DM application context.<br /><br />The transition to ACTIVE state starts either when the bundle is started or, in the case of lazy activation, after the bundle has been started and then<br />the first class is loaded from the bundle.<br /><br />3.<br /><br />Bundle-Version: 10.0.0<br /><br />Export-Package: com.test<br /><br />There is no relationship between the bundle and the package version. It's fairly often that a bundle version increases while the bundle package doesn't<br />(for example the new bundle provides only extra resources or extra packages).<br /><br />Exported packages by default are versioned at 0.0.0<br /><br />4.<br /><br />When I hit a bundles list command on the dm shell it shows as follows<br /><br />DM Shell output<br /><br />43 com.springsource.osgi.webcontainer.core 1.0.0.M1 ACTIVE<br />44 S com.springsource.osgi.webcontainer.tomcat 1.0.0.M1 ACTIVE<br />45 S com.springsource.server.web.core 2.0.0.RELEASE ACTIVE<br />46 com.springsource.server.web.dm 2.0.0.RELEASE ACTIVE<br />47 com.springsource.server.web.tomcat 2.0.0.RELEASE ACTIVE<br />48 com.springsource.javax.annotation 1.0.0 ACTIVE<br /><br />S means "Spring powered", i.e. with Spring (DM) XML files.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-33253389883563597822010-04-13T10:31:00.001-07:002010-04-13T10:34:32.499-07:00Useful Spring Utilities(API's)1. Default behaviour of Spring is that , when same names beans are loaded in a single applicationContext , the first bean will<br />be overridden by the latter.<br /><br />We had usecase where we required to get an error when multiple beans had the same name.<br /><br /><br />I have to extend ClassPathXmlApplicationContext and overide this method as it was protected.<br /><br /> @Override<br /> public void setAllowBeanDefinitionOverriding(<br /> boolean allowBeanDefinitionOverriding) {<br /> super.setAllowBeanDefinitionOverriding(allowBeanDefinitionOverriding);<br /> }<br /><br /><br /> ctx.setAllowBeanDefinitionOverriding(false);<br /> ctx.setConfigLocation("classpath*:/META-INF/spring/conf*.xml");<br /> ctx.afterPropertiesSet(); //will initialize the context<br /><br /><br />2. To get teh number of beans initialized by the application Context.<br /><br /> ctx.getBeanDefinitionCount());<br /><br /><br />3. To get the resouces read by created ApplicationContext based ona regular Expression.<br />[This is very handy in an integratde environment to exactlt know the resources ]<br /><br />I had to extend ClassPathXmlApplicationContext as this method was protected.<br /> <br /> @Override<br /> protected Resource[] getConfigResources() {<br /> // TODO Auto-generated method stub<br /> return super.getConfigResources();<br /> }<br /> <br /><br />Resource[] resources = ((ResourcePatternResolver) ctx).getResources("classpath*:/META-INF/spring/conf*.xml");<br /><br />where ctx is the initialized applicationContext.<br /><br /><br />4. If we need multiple definitons for <context:property-placeholder/><br /><br />Only one context:property-placeholder (the last one defined in the configuration files) will prevail.<br />You can define two separate PropertyPlaceholderConfigurers and work, only if the second one has a different placeholderPrefix and placeholderSuffix.<br /><br /><br />< bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" ><br />< property name="location" value="classpath:/com/foo/2.properties" / ><br />< property name="placeholderPrefix" value="#[" / ><br />< property name="placeholdersuffix" value="]" / ><br />< / bean ><br /><br />< bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" ><br />< property name="location" value="classpath:/1.properties" / ><br />< / bean ><br /><br /><br />Normal way of replacing is ${property1} and with new prefix and suffix #[]Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com2tag:blogger.com,1999:blog-8924547465677648029.post-47705523454272926602010-04-13T10:27:00.000-07:002010-04-13T10:34:32.500-07:00Difference between Classpath:* & Classpath*: in SpringThe difference between these two is the way the resources are found when a regular expression is given for match.<br /><br />classpath*: -> This special prefix specifies that all classpath resources that match the given name must be obtained<br />(internally, this essentially happens via a ClassLoader.getResources(...) call), and then merged to form the final application context definition.<br /><br />Ex classpath*:app*.xml && classpath:app*.xml is<br /><br />With spring xmls, app1.xml and app2.xml and beans in app2.xml referring to app1.xml<br /><br />- classpath:app*.xml will give errors if app1.xml and app2.xml are in two different classpath folders(It tries to find a matching app1 or app2 in classpath , and when<br /> found doesnt continue to search further with other classpath locations.)<br /><br /> - classpath*:app*.xml will never give errors(searches for all classpath folders)<br /><br />classpath* will search all classpath folder whereas classpath: will concentrate on one resource.<br /><br />This also works for location attribute of PropertyPlaceHolderConfig<br /><br /><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><br /> <property name="locations" value="classpath*:jdbc.properties"></property><br /></bean><br /><br />But important thing to be noted here is that property name is locations and not location.<br /><br /><br />One more difference with classpath*:config.xml and classpath:*config.xml<br /><br />is that<br /><br />classpath:*config.xml - if file(matching *config) isnt present it shows error in console<br /><br />classpath*:*config.xml just ignores teh error if no file is present in the classpath.<br /><br />classpath*: basically refers to a list of resources and a list can be empty.<br />classpath: simply points to a certain resource and if this is empty (where one would have expected it to exist) it would generate an error.<br /><br /><br />Note:<br /><br />Note that "classpath*:" when combined with Ant-style patterns will only work reliably with at<br />least one root directory(IMPORTANT) before the pattern starts, unless the actual target files<br />reside in the file system.This means that a pattern like "classpath*:*.xml" will not retrieve<br />files from the root of jar files but classpath*:META-INF/* will search as expected.Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com2tag:blogger.com,1999:blog-8924547465677648029.post-35315298559876616132009-12-12T01:24:00.001-08:002009-12-12T01:33:07.320-08:00Spring3 Features -TaskExecutor & TaskSchedulor<p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;">The Spring Framework provides abstractions for asynchronous execution and scheduling of tasks with the </span></span><code><b><span style="font-family:Courier New;font-size:85%;"><span style="font-size: 10pt; font-weight: bold;">TaskExecutor</span></span></b></code> and <code><b><span style="font-family:Courier New;font-size:85%;"><span style="font-size: 10pt; font-weight: bold;">TaskScheduler</span></span></b></code><span style="color:navy;"><span style="color: navy;"> </span></span>interfaces, respectively.</p> <h2><code><b><span style="font-family:Courier New;font-size:85%;"><span style="font-size: 10pt;">http://docs.google.com/fileview?id=0B-0gqvlsl_VvNTBlMDdmZmUtYWE4Ni00YmRhLTk0ODAtYWNhYjk4OGM5YTk1&hl=en<br />[Download - rename from pdf to rar]<br />[<span style="color:red;"><span style="color: red;">Attached is the sample code for both –with annotations</span></span>]</span></span></b></code></h2><code><b><span style="font-family:Courier New;font-size:85%;"><span style="font-size: 10pt;">1. <span style="color:red;"><span style="color: red;">TaskExecutor</span></span></span></span></b></code><h2> </h2> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;">Spring's </span></span><code><span style="font-family:Times New Roman;font-size:85%;"><span style="font-size: 10pt; font-family: "Times New Roman";">TaskExecutor</span></span></code> interface is identical to the <code><span style="font-family:Times New Roman;font-size:85%;"><span style="font-size: 10pt; font-family: "Times New Roman";">java.util.concurrent.Executor</span></span></code> interface.</p> <p><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> <b><span style="font-weight: bold;">ConcurrentTaskExecutor</span></b> : This implementation is a wrapper for a Java 5 java.util.concurrent.Executor.</span></span></p> <p><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> <b><span style="font-weight: bold;">ThreadPoolTaskExecuto</span></b>r : Spring's TaskExecutor implementation.<b><span style="font-weight: bold;"></span></b></span></span></p> <p class="MsoNormal" style=""><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> [<span style="color:black;"><span style="color: black;">org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor – Namespace:<task:executor></span></span><span style="color:teal;"><span style="color: teal;"> </span></span>]</span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;">Parametres : <b><span style="color:green;"><span style="color: green; font-weight: bold;">corePoolSize</span></span></b>,<b><span style="color:#339966;"><span style="color: rgb(51, 153, 102); font-weight: bold;">maxPoolSize</span></span></b>,<b><span style="color:#339966;"><span style="color: rgb(51, 153, 102); font-weight: bold;">queuecapacity</span></span></b>,<b><span style="color:#339966;"><span style="color: rgb(51, 153, 102); font-weight: bold;">rejection-policy</span></span></b></span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;">The executor will first try to use a free thread if the number of active threads is currently less than the <b><span style="color:#339966;"><span style="color: rgb(51, 153, 102); font-weight: bold;">core size</span></span></b>. If the core size has been reached, then the task will be added to the queue as long as <b><span style="color:#339966;"><span style="color: rgb(51, 153, 102); font-weight: bold;">its capacity</span></span></b> has not yet been reached. Only then, if the <b><span style="color:#339966;"><span style="color: rgb(51, 153, 102); font-weight: bold;">queue's capacity</span></span></b> <em><i><span style="font-family:Times New Roman;"><span style="font-style: normal;">has</span></span></i></em> been reached, will the executor create a new thread beyond the core size. If the max size has also been reached, then the executor will reject the task.</span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;">By default, when a task is rejected, a thread pool executor will throw a TaskRejectedException.<span class="MsoHyperlink"><u><span style="color:blue;"> </span></u></span><b><span style="color:#339966;"><span style="color: rgb(51, 153, 102); font-weight: bold;">CallerRunsPolicy</span></span></b>. Instead of throwing an exception or discarding tasks, that policy will simply force the thread that is calling the submit method to run the task itself. The idea is that such a caller will be busy while running that task and not able to submit other tasks immediately. Therefore it provides a simple way to throttle the incoming load while maintaining the limits of the thread pool and queue.</span></span></p> <h2><b><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;">2. </span></span></b><code><span style="font-family:Times New Roman;font-size:85%;color:red;"><span style="font-size: 10pt; font-family: "Times New Roman"; color: red;">TaskScheduler</span></span></code><span style="font-size:100%;"><span style="font-size: 12pt;"></span></span></h2> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> Spring 3.0 introduces a </span></span><code><span style="font-family:Times New Roman;font-size:85%;"><span style="font-size: 10pt; font-family: "Times New Roman";">TaskScheduler</span></span></code> with a variety of methods for scheduling tasks to run at some point in the future.</p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"><task:scheduler id="””" size="””"> - can be associated with a <b><span style="font-weight: bold;">pool size</span></b>.</span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;">Taskschedulor.schedule() takes a <b><span style="font-weight: bold;">trigger expression</span></b> based on which tasks will be scheduled.</span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Arial;font-size:85%;color:navy;"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></span></p> <p class="MsoNormal"><b><span style="font-family:Arial;font-size:85%;color:red;"><span style="font-size: 10pt; font-family: Arial; color: red; font-weight: bold;">Annotation Support </span></span></b></p> <p class="MsoNormal"><span style="font-family:Arial;font-size:85%;color:navy;"><span style="font-size: 10pt; font-family: Arial; color: navy;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;">Both have very easy annotation support.</span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;">@Async - This can be marked on any POJO method</span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;">@Scheduled- This annotation can be marked on any POJO method </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:#646464;"><span style="font-size: 12pt; color: rgb(100, 100, 100);"> </span></span></p> <div style="border: 1pt inset ; padding: 5pt;"><pre><span style="font-family:Times New Roman;font-size:100%;color:#646464;"><span style="font-size: 12pt; font-family: "Times New Roman"; color: rgb(100, 100, 100);">Just add </span></span><b><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt; font-family: "Times New Roman"; font-weight: bold;"><task:annotation-driven></span></span></b><span style="font-family:Times New Roman;font-size:100%;"><span style="font-size: 12pt; font-family: "Times New Roman";"> in the xml and give respective scheduler or executor as properties.</span></span></pre></div> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;"> </span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;">Currently with spring 3 RC2 and Spring Dm 2.0M6 – I could not use namespace support as they were giving some issues. It could be a <b><span style="font-weight: bold;">BUG</span></b> and I have raised this issue in the forum.</span></span></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:navy;"><span style="font-size: 12pt; color: navy;"> </span></span></p> <p class="MsoNormal"><b><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black; font-weight: bold;"><a rel="nofollow" target="_blank" href="http://forum.springsource.org/showthread.php?t=81676"><span style="color:black;"><span style="color: black;">http://forum.springsource.org/showthread.php?t=81676</span></span></a></span></span></b></p> <p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;"> In the attached sample code instead of using namespace I have used the entire class name.</span></span></p><p class="MsoNormal"><span style="font-family:Times New Roman;font-size:100%;color:black;"><span style="font-size: 12pt; color: black;"> Namespace should work with Spring 3 RC3 version.<br /></span></span></p>Sudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0tag:blogger.com,1999:blog-8924547465677648029.post-90279116439288412512009-12-12T01:14:00.000-08:002009-12-12T01:29:13.552-08:00Spring Integration+JMS(JBOSS)+OSGiI have a POC for spring integration to be used along with JBoss and OSGi in Spring Dm server 2.0M6.<br /><br />Code Sample<br />http://docs.google.com/fileview?id=0B-0gqvlsl_VvNzhiMzVmMzgtY2Y4Zi00YjJmLWJmNWQtMTIwMDZjNDViMmJl&hl=en<br />[<span style="font-weight: bold;">Download this pdf</span> - <span style="font-weight: bold;">Rename file from pdf to rar and extract</span>]<br /><br /><br /><span style="font-weight: bold;">SwitchBoardBundle </span>– Exposes connection factories as service<br /><br /> Exposes common thread pools as service<br /><br /> [Jboss ip values for connection factories are picked from property files]<br /><br /><br /><br /><span style="font-weight: bold;">Ara Bundle</span> - Start a timertask which puts message into a login channel.<br /><br /> This channel is exposed as a service which is imported by PamClient Channel<br /><br /> Ara bundles defines its own thread pool and receives connectionFactory service from switchboard bundle.<br /><br /><br /><br /><span style="font-weight: bold;">PamClient Bundle</span> - Listens to local events from ara bundle and remote events from Pamserver bundle<br /><br /> Imports login channel service from Ara bundle<br /><br /> Uses common thread pool defined in switchboard bundle<br /><br /> [Property file has values which can point each topic or queue to be hosted on a specific Jboss server] <br /><br /><br /><br /><span style="font-weight: bold;">PamServer Bundle</span> – generates events on regular time intervals which will be put into Jms queue using jms adapters.<br /><br />Also tested a use case where we could change connection factory without getting down the serverSudheer Krishnahttp://www.blogger.com/profile/02903946005300014831noreply@blogger.com0