ejb-3.1websphere-8

EJB Timer service: WTRN0006W: Transaction xxxx has timed out after 120 seconds


We have 4 timer jobs that run daily at different time. We are using internal Default persistent Timer scheduler with 4 threads for this. In this batch jobs we are retrieving contents of many DB2 tables and then storing each table data in a file either in a remote server or IBM Cloud Object Store. What we are noticing is that if any one the external resource (like DB2 or SFTP to remote server, or IBM COS) does to respond before 120 secs we get following exception:

    WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was 
    Thread[WebSphere_EJB_Timer_Service_WorkManager.Alarm Pool : 0,5,WebSphere_EJB_Timer_Service_WorkManager: WAS Scheduler: 
    WebSphere_EJB_Timer_Service]. The stack trace of this thread when the timeout occurred was: 
    java.net.SocketInputStream.socketRead0(Native Method)
    java.net.SocketInputStream.socketRead(SocketInputStream.java:127)
    java.net.SocketInputStream.read(SocketInputStream.java:182)
    java.net.SocketInputStream.read(SocketInputStream.java:152)

When this happens the batch job continues with next table, but when it is done with all tables, it restarts the same Job again. We would like to stop this restart of the batch job. Can you please help us how to do this.


Solution

  • There are a few different approaches to achieve the desired behavior:

    1. Increase the transaction timeout for the bean so that the timer method completes successfully. This is done in the ibm-ejb-jar-ext.xml deployment descriptor file, and would look something like this to increase transaction timeout to 600 seconds:

      ">

    Note: you will need to increase the maximum transaction timeout for the server as well : https://www.ibm.com/docs/en/was/9.0.5?topic=server-transaction-service-settings#TransactionService_totalTranLifetimeTimeout_displayName__title__1

    1. Change the bean timeout method to not use a transaction:

      @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

    2. Change the bean to use bean managed transactions, then either don't use a transaction or set the transaction timeout on UserTransaction:

      @TransactionManagement(TransactionManagementType.BEAN) userTransaction.setTransactionTimeout(600); userTransaction.begin();

    3. Configure the EJB TimerService to not retry. The timer method may still time-out, and so technically fail, but will not be retried by the container. Unfortunately, this is only possible for non-persistent timers, by setting the Maximum number of retries as documented here : https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/uejb_timerservice.html