Atomikos Forum |
|
Hi all,
I have a Spring based (SpringJUnit4ClassRunner) unit test method like this : @Test @Transactional public void testUpdateCustomer() { log.info("ENTRY testUpdateCustomer"); Customer customer = new Customer(); customer.setCustomerId("ronald-test-01"); Customer updatedCustomer = customerService.updateCustomer(customer); assertNotNull("null update customer", updatedCustomer); log.info("EXIT testUpdateCustomer"); } The service method is defined as follows: @Transactional(propagation=Propagation.MANDATORY) public Customer updateCustomer(Customer customer) { Note the Propagation.MANDATORY ! My logs show the following: 12:21:09,872 INFO main jta.JtaTransactionManager:469 - Using JTA UserTransaction: com.atomikos.icatch.jta.UserTransactionImp@67f31652 12:21:09,872 INFO main jta.JtaTransactionManager:480 - Using JTA TransactionManager: com.atomikos.icatch.jta.UserTransactionManager@83e96cf 12:21:09,991 DEBUG main annotation.AnnotationTransactionAttributeSource:106 - Adding transactional method 'testUpdateCustomer' with attribute: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '' 12:21:09,998 DEBUG main transaction.TransactionalTestExecutionListener:146 - Explicit transaction definition [PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''] found for test context [[TestContext@45c3987 testClass = CustomerServiceImplTest, locations = array<String>['classpath:/applicationContext-test.xml'], testInstance = com.xti.dbfact.webapp.service.CustomerServiceImplTest@42c4d04d, testMethod = testUpdateCustomer@CustomerServiceImplTest, testException = [null]]] 12:21:09,999 DEBUG main transaction.TransactionalTestExecutionListener:466 - Retrieved @TransactionConfiguration [null] for test class [class com.xti.dbfact.webapp.service.CustomerServiceImplTest] 12:21:10,000 DEBUG main transaction.TransactionalTestExecutionListener:483 - Retrieved TransactionConfigurationAttributes [[TransactionConfigurationAttributes@51e67ac transactionManagerName = 'transactionManager', defaultRollback = true]] for class [class com.xti.dbfact.webapp.service.CustomerServiceImplTest] 12:21:10,004 DEBUG main jta.JtaTransactionManager:365 - Creating new transaction with name [testUpdateCustomer]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; '' 12:21:10,036 INFO main atomikos:110 - THREADS: using JDK thread pooling... 12:21:10,051 INFO main atomikos:110 - createCompositeTransaction ( 300000 ): created new ROOT transaction with id 10.0.0.23.tm0000100012 12:21:10,056 TRACE main support.TransactionSynchronizationManager:258 - Initializing transaction synchronization You can see that: first Spring creates a new transaction called "testUpdateCustomer". Afterwards, apparently, Atomikos also creates another (new, second) transaction (id 10.0.0.23.tm0000100012). As I understand it, the Propagation.MANDATORY should mean that, in this case, only a single transaction is ever created ! I followed the spring integration docs on the atomikos website to the letter. Am I missing something here ? How many transaction are there really in this case, one or two ? Regards. |