MySQL和Infinispan - JTA实现 [英] MySQL and Infinispan - JTA implementation

查看:137
本文介绍了MySQL和Infinispan - JTA实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Tomcat下有一个Web应用程序,与Hibernate 4X,Spring 4X和HibernateTransactionManager集成为我们的事务管理器(目前是一个MySQL资源)。 作为我们的一部分配置分布,我们应该将 Infinispan 与我们的缓存管理器集成,以 以外的其他格式存储配置。意义,不是作为Hibernate二级缓存集成!



我设法将Infinispan与Spring集成,但现在我面临一个很大的问题,事实上,MySql事务和Infinispan 必须在同一个@Transactional 上。



我读到Spring JTA以及如何与Atomikos集成(例如)作为我们的全球交易经理,但我不确定我们是否可以将所有实体结合在一起工作,以及如何:($ / b
$ b

我需要知道是否有一个选项与Atomikos Spring JTA一起工作,因此Infinispan将认识到这个JTA实现,并将把 MySql和Infinispan作为一个全局事务处理!(2PC) 谢谢!

解决方案

起初我会建议将Spring + Hibernate + JTA配置在一起,这里有一个很好的 tut orial 。如果你正确配置了所有东西 - 你应该有一个类型为 TransactionManager 的bean。在上面的教程中,它被配置在这个块中:

  @Bean(initMethod =init,destroyMethod =close)
public TransactionManager transactionManager()throws Throwable {
UserTransactionManager userTransactionManager = new UserTransactionManager();
userTransactionManager.setForceShutdown(false);
返回userTransactionManager;
}

现在您可以配置Infinispan使用此事务管理器。实现这一点的最简单方法是实现您自己的的TransactionManagerLookup 。这应该返回上面创建的事务管理器。



最后,您必须创建事务缓存,如下所示:

  < local-cache name =transactional> 
< transaction mode =FULL_XA/>
< / local-cache>

之后,所有东西都应该与同一个事务管理器一起工作,并且Spring应该处理单个 @Transactional 注释。


We have an web application under Tomcat, integrated with Hibernate 4X, Spring 4X and HibernateTransactionManager as our transaction manager (currently one MySQL resource).

As part of our configuration distribution, we should integrate with Infinispan as our cache manager to store configuration with other format than in the MySQL. Meaning, not as Hibernate second level cache integration!

I managed to integrate Infinispan with Spring but now I'm facing a big problem due to the fact the MySql transaction and Infinispan must be on the same @Transactional.

I read about Spring JTA and how to integrate with Atomikos (e.g.) as our Global Transaction manager but I'm not sure if we can combine the whole entities to work together and how :(

I need to know if there's an option to work with Atomikos Spring JTA so the Infinispan will recognize this JTA implementation and will handle the MySql and Infinispan as one global transaction! (2PC)

Thanks!

解决方案

At first I would suggest to configure Spring + Hibernate + JTA together. Here is a very nice tutorial. If you configured everything correctly - you should have one bean of a type TransactionManager. In above tutorial it is configured inside this block:

@Bean(initMethod = "init", destroyMethod = "close")
public TransactionManager transactionManager() throws Throwable {
  UserTransactionManager userTransactionManager = new UserTransactionManager();
  userTransactionManager.setForceShutdown(false);
  return userTransactionManager;
}

Now you may configure Infinispan to use this transaction manager. The easiest way to achieve this, is to implement your own TransactionManagerLookup. This should return the transaction manager, which was created above.

Finally you have to create transactional cache, like this:

<local-cache name="transactional">
    <transaction mode="FULL_XA"/>
</local-cache>

After that everything should work with the same Transaction Manager and Spring should handle everything within single @Transactional annotation.

这篇关于MySQL和Infinispan - JTA实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆