简体   繁体   English

组件集成的春季交易策略

[英]spring transactions strategy for component integration

We have a typical situation. 我们有一个典型的情况。

Two java service components are being developed in parallel. 两个java服务组件正在并行开发。

Lets say A and B. A is JMS application that picks up message from queue and does some business rules processing. 假设A和B。A是JMS应用程序,它从队列中提取消息并进行一些业务规则处理。 A uses B for database persistence. A使用B进行数据库持久化。 B does all database operations. B执行所有数据库操作。

So, that means B's methods are called from A always. 因此,这意味着总是从A调用B的方法。 A is developed using WebsphereUowTransactionManager (server specific subclass of JtaTransactionManager) while B is using JpaTransactionManager. A使用WebsphereUowTransactionManager (JtaTransactionManager的服务器特定子类)开发,而B使用JpaTransactionManager。 A uses programmatic transaction model (yes, we need it) while B uses declarative model (@Transaction annotation). A使用程序化事务模型(是的,我们需要它),而B使用声明性模型(@Transaction注解)。 Both were developed using separate bean configurations. 两者都是使用单独的bean配置开发的。

Now, in integration, we are facing transaction exceptions. 现在,在集成中,我们面临交易异常。 I believe it is due to mis-match between transaction models of A and B. Theoritcally, B will use A's transactional context which is programatic. 我认为这是由于A和B的事务模型之间的不匹配所致。从理论上讲,B将使用A的程序化事务上下文。 This makes B's declarative model redundant. 这使得B的声明性模型变得多余。

So, the question is what should be the correct combined transaction strategy to integrate A and B? 因此,问题是将A和B整合在一起的正确组合交易策略应该是什么?

My understanding - A uses programmatic transactions so B also must use programmatic model. 我的理解-A使用程序化交易,因此B也必须使用程序化模型。

I would add some mediating component so all the interactions between A and B would go through a single service (unified TX management strategy). 我将添加一些中介组件,以便A和B之间的所有交互都将通过单个服务(统一的TX管理策略)进行。 BTW: you can use JmsTransactionManager for A. More on Spring TX Management here 顺便说一句:您可以将JmsTransactionManager用于A。更多关于Spring TX Management的信息,请点击这里

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

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