在事务期间提交多个连接

发布于 2024-09-11 09:17:00 字数 61 浏览 2 评论 0原文

如果连接取自 weblogic 中的数据源,我可以在一个事务期间创建多个连接并对其执行提交吗? ???请帮忙

can i create multiple connections during one transaction and perform commit on them provided the connection are taken from data source in weblogic. ??? please help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青萝楚歌 2024-09-18 09:17:00

你的意思是来自不同的数据源?

当然可以。这就是 JTA 的用途。

只需确保所涉及的数据源的驱动程序是 XA 感知的。


已编辑
我明白你的意思了。

我开发的应用程序就有这样的功能。假设您的请求处理例程有一些基本的流程控制或处理程序结构,您始终可以仅为错误处理部分启动一个新事务,提交该新事务,然后回滚原始事务。

使用 Spring + 声明式事务控制,您需要在错误处理例程周围声明一个事务,并使用 REQUIRES_NEW 传播策略

You mean from different datasource?

Of course you can. That's what JTA are for.

Just make sure that involved datasources' driver are XA-awared.


Edited
I got what you mean.

The application I developed has such feature. Assume you have some basic flow control or handler structure for your request processing routine, you can always start a new transaction just for the error handling part, commit that new tranasction, and rollback the original one.

With Spring + Declarative transaction control you need to have a transaction declared around the error handling routine, with a REQUIRES_NEW propagation policy

陌生 2024-09-18 09:17:00

根据您想要有效地使用自治事务来记录失败的评论,您可以使用数据源中的第二个连接并提交该连接,同时回滚原始失败的连接(这不需要 XA;您的问题表明您想同时提交两个连接);或者如果您可以使用实际的自主事务< /a> 在回滚之前处理原始连接内的日志记录。这可能更简单、更干净,特别是如果您的失败确实来自包调用,因为它可以在失败发生时进行处理,而不是让客户担心它。概要:

PROCEDURE log_failure(...)
IS
    PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
    insert ...
    commit;
END log_failure;

Based on the comment that you want, effectively, an autonomous transaction to log a failure, you can either use a second connection from your datasource and commit that while rolling back the original failed one (which doesn't require XA; the wording in your question suggests you want to commit both connections simultaneously); or if you can use an actual autonomous transaction to handle the logging inside your original connection before rolling back. This is probably simpler and cleaner, particularly if your failure is really coming from a package call anyway as it can be dealt with as the failure occurs rather than having the client worry about it. In outline:

PROCEDURE log_failure(...)
IS
    PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
    insert ...
    commit;
END log_failure;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文