cancel
Showing results for 
Search instead for 
Did you mean: 

StandaloneMybatisTransactionContext used with JtaCfg?

chris_joelly
Champ in-the-making
Champ in-the-making
Hello,

i configured Activiti in the following way:


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd">
   <jee:jndi-lookup jndi-name="java:appserver/TransactionManager" id="transactionManager" />
   <bean id="processEngineConfiguration"
      class="org.activiti.engine.impl.cfg.JtaProcessEngineConfiguration">
      <property name="transactionManager" ref="transactionManager"/>
      <property name="transactionsExternallyManaged" value="true" />
      <property name="dataSourceJndiName" value="jdbc/MysqlErp" />
      <property name="databaseSchemaUpdate" value="true" />
      <property name="databaseType" value="mysql" />
   </bean>
</beans>

but when i activate java.util.logging with level FINE then i see lots of messages which writes that the StandaloneMybatisTransactionContext is used
within the engine and commits are done:


[#|2011-08-15T13:19:16.770+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.interceptor.LogInterceptor|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.interceptor.LogInterceptor;MethodName=execute;|— starting GetTaskFormCmd ——————————————————–|#]
[#|2011-08-15T13:19:16.772+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.db.DbSqlSession|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.db.DbSqlSession;MethodName=flush;|flush summary:|#]
[#|2011-08-15T13:19:16.772+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.db.DbSqlSession|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.db.DbSqlSession;MethodName=flush;|now executing flush…|#]
[#|2011-08-15T13:19:16.772+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext;MethodName=commit;|firing event committing…|#]
[#|2011-08-15T13:19:16.772+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext;MethodName=commit;|committing the ibatis sql session…|#]
[#|2011-08-15T13:19:16.772+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext;MethodName=commit;|firing event committed…|#]
[#|2011-08-15T13:19:16.772+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.interceptor.LogInterceptor|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.interceptor.LogInterceptor;MethodName=execute;|— GetTaskFormCmd finished ——————————————————–|#]
[#|2011-08-15T13:19:16.773+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.interceptor.LogInterceptor|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.interceptor.LogInterceptor;MethodName=execute;|                                                                                                    |#]
[#|2011-08-15T13:19:16.774+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.interceptor.LogInterceptor|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.interceptor.LogInterceptor;MethodName=execute;|                                                                                                    |#]
[#|2011-08-15T13:19:16.774+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.interceptor.LogInterceptor|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.interceptor.LogInterceptor;MethodName=execute;|— starting TaskQueryImpl ——————————————————–|#]
[#|2011-08-15T13:19:16.790+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.db.DbSqlSession|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.db.DbSqlSession;MethodName=flush;|flush summary:|#]
[#|2011-08-15T13:19:16.791+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.db.DbSqlSession|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.db.DbSqlSession;MethodName=flush;|now executing flush…|#]
[#|2011-08-15T13:19:16.791+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext;MethodName=commit;|firing event committing…|#]
[#|2011-08-15T13:19:16.791+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext;MethodName=commit;|committing the ibatis sql session…|#]
[#|2011-08-15T13:19:16.791+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.cfg.standalone.StandaloneMybatisTransactionContext;MethodName=commit;|firing event committed…|#]
[#|2011-08-15T13:19:16.791+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.interceptor.LogInterceptor|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.interceptor.LogInterceptor;MethodName=execute;|— TaskQueryImpl finished ——————————————————–|#]
[#|2011-08-15T13:19:16.792+0200|FINE|glassfish3.1.1|org.activiti.engine.impl.interceptor.LogInterceptor|_ThreadID=21;_ThreadName=Thread-2;ClassName=org.activiti.engine.impl.interceptor.LogInterceptor;MethodName=execute;|    

does this mean that Activiti is triggering commit's to the datasource?
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
That's a bit misleading, in the processEngineonfigurationIml:

protected void initTransactionFactory() {
    if (transactionFactory==null) {
      if (transactionsExternallyManaged) {
        transactionFactory = new ManagedTransactionFactory();
      } else {
        transactionFactory = new JdbcTransactionFactory();
      }
    }
  }

The transaction-context (in this case StandaloneMybatisTransactionContext) is used for notifying transaction-listeners (internal) and is called after command-context closes (also internal). In case of JTA, the commit won't do anything, since the SQLSessions are managed by JTA I whould presume.

Can you write a test that confirms rollback-behaviour when activiti participates in a JTA-transaction?

When using Spring, a SpringTransactionContext is used -> this uses the PlatformTransactionManager instead of the SQLSession.