Wednesday, December 15, 2010

Get Weblogic Transaction details - timeout, time to live

weblogic.transaction.TransactionHelper
http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13941/weblogic/transaction/TransactionHelper.html

weblogic.transaction.Transaction - extends javax.transaction.Transaction
http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e13941/weblogic/transaction/Transaction.html


EJB 3.0 Metadata Annotations Reference
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/ejb30/annotations.html#wp1438355

package dave;

import java.sql.Connection;
import weblogic.javaee.TransactionTimeoutSeconds;
import java.sql.SQLException;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import javax.transaction.SystemException;

import weblogic.transaction.Transaction;
import weblogic.transaction.TransactionHelper;

/**
* Session Bean implementation class TestSesssionEJB
*/
@Stateless(mappedName = "TestSesssionEJB")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@TransactionTimeoutSeconds(1800)
public class TestSesssionEJB implements TestSesssionEJBRemote, TestSesssionEJBLocal {

/**
* Default constructor.
*/
public TestSesssionEJB() {
}


public int testTransactionTimeout(int timeout) {

int out = 0;

TransactionHelper th = weblogic.transaction.TransactionHelper.getTransactionHelper();

weblogic.transaction.Transaction transaction = (Transaction) th.getTransaction();

System.out.println("Transaction: "+ transaction);

try {
System.out.println("Transaction status: "+ transaction.getStatus());
} catch (SystemException e) {
e.printStackTrace();
}

long timeFromBegin = transaction.getMillisSinceBegin();
long timeToLive = transaction.getTimeToLiveMillis();

System.out.println("timeFromBegin" + timeFromBegin + " timeToLive" + timeToLive);

return out;

}

}




Default 900s set in JTA
Transaction:  Name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)],Xid=BEA1-000002B089C73057A4BD(11628244),Status=Active,
numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=899,activeThread=Thread[[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads],SCInfo[base_domain+AdminServer]=(state=active),properties=({weblogic.transaction.name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+,
XAResources={WSATGatewayRM_AdminServer_base_domain},NonXAResources={})],
CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+)
Transaction status: 0
timeFromBegin934 timeToLive899000



Changed on EJB to 1800s
Transaction:  Name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)],Xid=BEA1-000302B089C73057A4BD(11110649),Status=Active,
numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=1800,
activeThread=Thread[[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads],SCInfo[base_domain+AdminServer]=(state=active),properties=({weblogic.transaction.name=[EJB dave.TestSesssionEJB.testTransactionTimeout(int)]}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+, XAResources={WSATGatewayRM_AdminServer_base_domain},NonXAResources={})],
CoordinatorURL=AdminServer+localhost:7001+base_domain+t3+)
Transaction status: 0
timeFromBegin12 timeToLive1800000

No comments:

Post a Comment