简体   繁体   English

Infinispan事务-无法从Spring4获取TransactionManager

[英]Infinispan transaction - can not get TransactionManager from Spring4

I need to configure Infinispan as cache provider for my Spring project. 我需要将Infinispan配置为Spring项目的缓存提供程序。 It's because his transaction functions. 这是因为他的交易起作用。 The problem is with Spring using PlatformTransactionManager and Infinispan needs javax.transaction.TransactionManager. 问题是Spring使用PlatformTransactionManager,而Infinispan需要javax.transaction.TransactionManager。 Is it possible to configure Infinispan TransactionManagerLookup with Spring provided PlatformTransactionManager? 是否可以使用Spring提供的PlatformTransactionManager配置Infinispan TransactionManagerLookup?

I am using JpaTransactionManager as TransactionManager. 我正在使用JpaTransactionManager作为TransactionManager。 Version of Infinispan is 7.2.3.Final, Spring4. Infinispan的版本是7.2.3.Final,Spring4。

Infinispan TransactionManagerLookup returns a JTA TransactionManager implementation. Infinispan TransactionManagerLookup返回JTA TransactionManager实现。 However you are using a PlatformTransactionManager which has nothing to do with JTA. 但是,您正在使用与JTA无关的PlatformTransactionManager

So there are at least 2 ways of of dealing with this: 因此,至少有两种处理方式:

  • You may develop and adapter between PlatformTransactionManager and JTA TransactionManager and return it via TransactionManagerLookup. 您可以在PlatformTransactionManager和JTA TransactionManager之间开发适配器,并通过TransactionManagerLookup返回它。
  • A much better approach is to configure Spring to use JTA with your entities (you will probably find many example on the internet but the key point here is that you will need some JTA implementation like Narayana for example). 更好的方法是将Spring配置为与您的实体一起使用JTA(您可能会在互联网上找到很多示例,但这里的关键点是您将需要某些JTA实现,例如Narayana )。 Then Infinispan should find the JTA Transaction Manager automatically (or you might specify it manually using TransactionManagerLookup). 然后,Infinispan应该会自动找到JTA事务管理器(或者您可以使用TransactionManagerLookup手动指定它)。

It looks like JpaTransactionManager is able to bind only one target and I will need JtaTransactionManager. 看起来JpaTransactionManager只能绑定一个目标,而我将需要JtaTransactionManager。 Hopefully it's possible to bind it under Spring's PlatformTransactionManager. 希望可以将其绑定到Spring的PlatformTransactionManager下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM