Search code examples
jbosstransactionsjmxjta

How to change value of com.arjuna.ats.jbossatx.jta.TransactionManagerService TransactionTimeout at the run-time?


We have JBoss [EAP] 4.3.0.GA_CP01 environment and I need to modify the

TransactionTimeout 

property of

com.arjuna.ats.jbossatx.jta.TransactionManagerService

but whenever i try to change the value via MBean from JMX-Console; following stacktrace shows up:

java.lang.IllegalStateException: Cannot set transaction timeout once MBean has started
com.arjuna.ats.jbossatx.jta.TransactionManagerService.setTransactionTimeout(TransactionManagerService.java:323)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jboss.mx.interceptor.AttributeDispatcher.invoke(AttributeDispatcher.java:136)
org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor.invoke(ModelMBeanAttributeInterceptor.java:103)
org.jboss.mx.interceptor.PersistenceInterceptor.invoke(PersistenceInterceptor.java:76)
org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
org.jboss.mx.server.AbstractMBeanInvoker.setAttribute(AbstractMBeanInvoker.java:461)
org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:608)
org.jboss.jmx.adaptor.control.Server.setAttributes(Server.java:206)
org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.updateAttributes(HtmlAdaptorServlet.java:236)
org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:98)
org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

Is there a way programmatically to change the value of TransactionTimeout without bouncing the server at the run-time??


Solution

  • Thank you Nicholas!

    Here is the Java code which can be used to change the transaction timeout on runtime...

    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());
    

    And as you quoted, Note that this will not change the value reported in the MBean's TransactionTimeout attribute however the value will be effective for all transactions post this operation.