title: Performance of JMS Queue connections
body: <p>In my spring batch, i'm using Oracle DB and IBM WMQ and implemented Atomikos Transaction management and Spring Partitioning.</p>
  
  <p>Requirement is, need to read 2 million records from database and after processing, post the same messages(1 message size=2kb) into WMQ and update 2 million records in database as well.</p>
  
  <p>Following is my code configuration.
  Queue configuration:
  `</p>
  
  <pre><code>&lt;bean id="atomikosJmsConnectionFactory" class="com.atomikos.jms.AtomikosConnectionFactoryBean" init-method="init" destroy-method="close"&gt;
          &lt;property name="uniqueResourceName" value="WMQ_MQSeries_XA_RMI" /&gt;
          &lt;property name="xaConnectionFactory"&gt;
              &lt;bean class="com.ibm.mq.jms.MQXAConnectionFactory"&gt;
                  &lt;property name="connectionNameList" value="127.0.0.1(1414)" /&gt;
                  &lt;property name="queueManager" value="LWMQ" /&gt;
                  &lt;property name="channel" value="LCHNL" /&gt;
                  &lt;property name="transportType"&gt;
                    &lt;util:constant static-field="com.ibm.msg.client.wmq.WMQConstants.WMQ_CM_CLIENT" /&gt;
                  &lt;/property&gt;
                  &lt;property name="clientReconnectOptions"&gt;
                    &lt;util:constant static-field="com.ibm.msg.client.wmq.WMQConstants.WMQ_CLIENT_RECONNECT" /&gt;
                  &lt;/property&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
          &lt;property name="ignoreSessionTransactedFlag" value="${mq.ignoreSessionTransactedFlag:false}"&gt;&lt;/property&gt;
          &lt;property name="borrowConnectionTimeout" value="300"&gt;&lt;/property&gt;
          &lt;property name="maxPoolSize" value="50"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
       &lt;bean id="jmsTemplate"  class="org.springframework.jms.core.JmsTemplate"&gt;
          &lt;property name="connectionFactory" ref="atomikosJmsConnectionFactory" /&gt;
          &lt;property name="sessionTransacted" value="true"/&gt;
          &lt;property name="sessionAcknowledgeMode" value="0" /&gt;
          &lt;property name="receiveTimeout" value="2000" /&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>Spring Job Configuration:</p>
  
  <pre><code>&lt;batch:step id="masterStep"&gt;
        &lt;batch:partition step="slaveStep" partitioner="customPartitioner"&gt;
          &lt;batch:handler task-executor="taskExecutor" /&gt;
        &lt;/batch:partition&gt;
      &lt;/batch:step&gt;
      &lt;batch:listeners&gt;
        &lt;batch:listener ref="loadJobListener" /&gt;
      &lt;/batch:listeners&gt;
    &lt;/batch:job&gt;
  
    &lt;batch:step id="slaveStep"&gt;
      &lt;batch:tasklet transaction-manager="atomikosTransactionManager"&gt;
        &lt;batch:chunk chunk-completion-policy="chunkCompletionPolicy" /&gt;
      &lt;/batch:tasklet&gt;
    &lt;/batch:step&gt;
  
  &lt;bean id="taskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" &gt;
      &lt;property name="threadNamePrefix" value="L-Thread-"&gt;&lt;/property&gt;
      &lt;property name="concurrencyLimit" value="20"&gt;&lt;/property&gt;
    &lt;/bean&gt;
  
   &lt;bean id="chunkTimeout"
      class="org.springframework.batch.repeat.policy.TimeoutTerminationPolicy"&gt;
      &lt;constructor-arg value="36000" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="commitCount"
      class="org.springframework.batch.repeat.policy.SimpleCompletionPolicy"&gt;
      &lt;property name="chunkSize" value="100" /&gt;
    &lt;/bean&gt;
  
  &lt;bean id="chunkCompletionPolicy"
      class="org.springframework.batch.repeat.policy.CompositeCompletionPolicy"&gt;
      &lt;property name="policies"&gt;
        &lt;list&gt;
          &lt;ref bean="commitCount" /&gt;
          &lt;ref bean="chunkTimeout" /&gt;
        &lt;/list&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  </code></pre>
  
  <p>Here is my linux server configuration:
  Model : Intel(R) Xeon(R) CPU v4 @ 2.60GHz
  Architecture: x86_64
  No of CPU : 16
  RAM : 100GB</p>
  
  <p>Currently, the job takes 120 min to finish the task(including 2 million messages posting into MQ and updating into database)</p>
  
  <p>my Observation: Most of the time Threads are in waiting state for MQ connection.
  Following is the Visual-VM screenshot of threaddump.</p>
  
  <pre><code>"L-Thread-4" #101 prio=5 os_prio=0 tid=0x000000002349e000 nid=0xcabc waiting on condition [0x00000000324cd000]
     java.lang.Thread.State: TIMED_WAITING (parking)
      at sun.misc.Unsafe.park(Native Method)
      - parking to wait for  &lt;0x0000000771afc540&gt; (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
      at java.util.concurrent.locks.LockSupport.parkNanos(Unknown Source)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
      at com.ibm.ws.xs.xio.actor.impl.FutureImpl.await(FutureImpl.java:268)
      at com.ibm.ws.xs.xio.actor.impl.FutureImpl.get(FutureImpl.java:316)
      at com.ibm.ws.xsspi.xio.dispatch.MessageDispatcher.askAndGet(MessageDispatcher.java:373)
      at com.ibm.ws.xs.xio.actor.impl.ActorRefImpl.askAndGet(ActorRefImpl.java:106)
      at com.ibm.ws.objectgrid.client.XIOClientCoreMessageHandler.sendMessageInternal(XIOClientCoreMessageHandler.java:372)
      at com.ibm.ws.objectgrid.client.XIOClientCoreMessageHandler.sendMessage(XIOClientCoreMessageHandler.java:142)
      at com.ibm.ws.objectgrid.client.CommonClientCoreMessageHandler.sendGetRequest(CommonClientCoreMessageHandler.java:229)
      at com.ibm.ws.objectgrid.client.RemoteTransactionCallbackImpl.mapGet(RemoteTransactionCallbackImpl.java:1953)
      at com.ibm.ws.objectgrid.client.RemoteCacheLoader.get(RemoteCacheLoader.java:497)
      at com.ibm.ws.objectgrid.map.BaseMap.getRaw(BaseMap.java:4846)
      at com.ibm.ws.objectgrid.DiffMap.lookForKey(DiffMap.java:1391)
      at com.ibm.ws.objectgrid.DiffMap.get(DiffMap.java:981)
      at com.ibm.ws.objectgrid.ObjectMapImpl.get(ObjectMapImpl.java:451)
      at com.ibm.ws.objectgrid.ObjectMapImpl.get(ObjectMapImpl.java:411)
      at com.ibm.websphere.objectgrid.spring.ObjectGridCache.get(ObjectGridCache.java:290)
  </code></pre>
  
  <p>How can i fix this issue to speed up my process..?</p>
  
  <p>I need to finish this job process within 1 hour.</p>