Reputation: 14363
I asked this question earlier How to change value of com.arjuna.ats.jbossatx.jta.TransactionManagerService TransactionTimeout at the run-time?
As per the answer provided I found this java code to do my job:
MBeanServer mBeanServer = MBeanServerLocator.locateJBoss();
TransactionManagerDelegate tmd = (TransactionManagerDelegate) mBeanServer.getAttribute(new ObjectName("jboss:service=TransactionManager"), "TransactionManager");
System.out.println("Prev: " + tmd.getTransactionTimeout());
tmd.setTransactionTimeout(200);
System.out.println("New: " + tmd.getTransactionTimeout());
Now here is the problem... the code executes fine but when i check from JMX-console the Transaction Timeout is still the same.
When i debug i found that TM instance fetched from mBeanServer and TM instance available on jmx-console are different!
Is there any way to update the TM instance which is available on JMX-Console?
Upvotes: 1
Views: 905
Reputation: 14363
The code above works and does change the transaction timeout. As @Nicholas mentioned They are different object instances, but there is only one transaction manager.
however The value reported in the MBean's TransactionTimeout attribute doesn't change
and this caused me to ask this question on the first place.
Upvotes: 0
Reputation: 16056
Bharat;
They are different object instances, but there is only one transaction manager. What you're seeing is simply two different wrappers/proxies for the internal Arjuna transaction manager core. This code acquires the current transaction from the two different proxies, but the actual transaction UUID is the same:
def txManager = mbeanserver.getAttribute(JMXHelper.objectName("jboss:service=TransactionManager"), "TransactionManager");
TX.exec({
println txManager.getTransaction();
println mbeanserver.getAttribute(JMXHelper.objectName("jboss:service=TransactionManager"), "UserTransaction");
assert mbeanserver.getAttribute(JMXHelper.objectName("jboss:service=TransactionManager"), "UserTransaction").toString().replace("Transaction: ", "").equals(txManager.getTransaction().toString())
println "Timeout:${txManager.getTransactionTimeout()}";
});
txManager.setTransactionTimeout(200);
TX.exec({
println txManager.getTransaction();
println mbeanserver.getAttribute(JMXHelper.objectName("jboss:service=TransactionManager"), "UserTransaction");
assert mbeanserver.getAttribute(JMXHelper.objectName("jboss:service=TransactionManager"), "UserTransaction").toString().replace("Transaction: ", "").equals(txManager.getTransaction().toString())
println "Timeout:${txManager.getTransactionTimeout()}";
});
Output:
TransactionImple < ac, BasicAction: ae60d43:d590:4ffc7013:265841 status: ActionStatus.RUNNING > Transaction: TransactionImple < ac, BasicAction: ae60d43:d590:4ffc7013:265841 status:ActionStatus.RUNNING > Timeout:200 TransactionImple < ac, BasicAction: ae60d43:d590:4ffc7013:265842 status: ActionStatus.RUNNING > Transaction: TransactionImple < ac, BasicAction: ae60d43:d590:4ffc7013:265842 status: ActionStatus.RUNNING > Timeout:400
Upvotes: 1