Hello,

I am using SpringTransactionManager & HibernateTransactionManager in a
Spring ChainedTransactionManager in order to rollback all database and cache
updates
in the event of there being any failures in either transaction manager.

I am finding that rollbacks in HibernateTransactionManager do cause
rollbacks in SpringTransactionManager but not vice versa - database changes
are not rolled back when Ignite transactions rollback.

Here are the logs from my test:

2018-02-02 15:09:00,509 DEBUG [unknown 192.168.1.10] main unknown unknown
{AbstractPlatformTransactionManager.java:367} - Creating new transaction
with name [com.dna.chain.service.impl.TestServiceImpl.testeroo]:
PROPAGATION_REQUIRED,ISOLATION_DEFAULT; 'chainedTransactionManager'
2018-02-02 15:09:00,514 DEBUG [unknown 192.168.1.10] main unknown unknown
{AbstractPlatformTransactionManager.java:851} - Initiating transaction
rollback
2018-02-02 15:09:00,514 DEBUG [unknown 192.168.1.10] main unknown unknown
{AbstractPlatformTransactionManager.java:1020} - Resuming suspended
transaction after completion of inner transaction

Here are the configured transaction managers:

@Bean
public ChainedTransactionManager chainedTransactionManager(
PlatformTransactionManager hibernateTxMgr, PlatformTransactionManager
igniteTxMgr) {
        ChainedTransactionManager transactionManager = new
ChainedTransactionManager(
            new PlatformTransactionManager[] { hibernateTxMgr, igniteTxMgr
});
        return transactionManager;
 }

@Bean
public PlatformTransactionManager hibernateTxMgr(SessionFactory
sessionFactory) {
        HibernateTransactionManager manager = new
HibernateTransactionManager(sessionFactory);
        return manager;
}

@Bean
public PlatformTransactionManager igniteTxMgr(IgniteSpringBean ignite)
throws IOException {
        SpringTransactionManager igniteTxMgr = new
SpringTransactionManager();
        igniteTxMgr.setGridName(ignite.getConfiguration().getGridName());
        return igniteTxMgr;
}

And test code:

@Transactional("chainedTransactionManager")
public void testeroo(Consumer<Params> consumer, Params params) {
        consumer.accept(params);
}

// Inserts params into databases first and then puts params into cache and
throws exception
public final class Scenario2 implements Consumer<Params> {

        @Override
        public void accept(Params params) {
            
            scheduleDao.saveOrUpdate(schedule);
           jobConfigDao.saveOrUpdate(jobConfig);
           cache_1.put(pair.getFirst(), pair.getSecond());
           throw new RuntimeException("inbound is null")
        }
   }






--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to