【问题标题】:Implementing Spring ChainedTransactionManager according to the "best efforts 1PC" pattern [closed]根据“尽力而为 1PC”模式实现 Spring ChainedTransactionManager [关闭]
【发布时间】:2013-03-26 22:09:04
【问题描述】:

尽最大努力 1PC 在this post 中有很好的描述。为 SpringSource 工作的作者 David Syer 提供了一个扩展 Spring AbstractPlatformTransactionManager 类的 ChainedTransactionManager 的实现。

这个特定的事务管理器可以启动 n 个事务,例如 JDBC 或 JMS 会话,并使用 AbstractPlatformTransactionManagern 个实例执行提交/回滚,每个资源一个。这在 XA 驱动程序不可用的情况下非常有用。由于帖子很旧,代码在 Spring 2.5 上运行良好,但在 Spring 3+ 上失败。

在 Spring 3+ 中有一个 request ticket 来实现类似的功能。我愿意试一试,但我想我会先问:那里有什么实现吗?

谢谢

【问题讨论】:

  • 我认为您可以尝试使用 spring-data-neo4j 中的 ChainedTransactionManager,但是现在什么样的数据库不提供 xa 驱动程序?如果您需要其他想法,这篇博客infinispan.blogspot.com.ar/2011/06/… 展示了缓存系统如何挂钩到 JTA 同步,以避免 XA,就性能而言。
  • 谢谢我现在正在使用它,有人在 Spring 的 Jira 上建议它。例如 Vectorwise 不提供 XA 驱动程序。乔瓦尼
  • 您好 Giovanni,我们也在尝试使用尽力而为 1PC 模式为我们的 spring 批处理应用程序进行类似的设置。您能否告诉我们您使用这种方法的经验。如果您可以向我们提供示例配置文件以供参考,那将非常有帮助。我的电子邮件 ID 是 ravikiran763@gmail.com 。提前谢谢你
  • @rave763 我不再从事这个项目,也无法再访问代码,但那时我对ChainedTransactionManager 很幸运。我的配置主要是自定义的,即不是您的标准 Spring 配置。反正我从不喜欢 XML 配置方法。

标签: java spring jdbc transactions jms


【解决方案1】:

按照 Luciano 的建议,我在以下位置找到了一个完美的 ChainedTransactionManager 实现:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-neo4j-tx</artifactId>
  <version>2.2.0.RELEASE</version>
</dependency>

类名:org.springframework.data.neo4j.transaction.ChainedTransactionManager

编辑

ChainedTransactionManager 现在是 Spring Data Commons 的一部分 version 1.6.1

【讨论】:

  • 嘿,你们知道是否可以从不同的线程使用多个 ChainedTransactionManager 实例(现已移至 Spring Data Commons)来处理跨不同资源的事务?还是必须是单身人士?
  • @Giovnni Botta 猜猜我正在处理谁的旧代码? :)
  • @JohnHumphreys-w00te 祝你好运!
猜你喜欢
  • 1970-01-01
  • 2010-12-21
  • 1970-01-01
  • 2023-01-12
  • 1970-01-01
  • 2018-01-31
  • 1970-01-01
  • 1970-01-01
  • 2021-08-22
相关资源
最近更新 更多