简体   繁体   English

Web服务交易控制

[英]Web Service Transaction Control

I'm working on some remote api invoking recently. 我正在研究一些最近调用的远程api。 This is the background. 这就是背景。

In a transaction, let's say a payment workflow, after the customer finished his payment successfully through paypal api, I need to update my local db (let's say update order_table, update score_table). 在一笔交易中,假设有一个付款工作流程,在客户通过Paypal API成功完成付款后,我需要更新我的本地数据库(比如说update order_table,update score_table)。

It would be like this: 就像这样:

Whole Transaction 整个交易
{ {
invoking paypal api - success 调用Paypal API-成功
update order_table - success 更新order_table-成功
update score_table - failed 更新score_table-失败
} }

If the invoking paypal api is a local method invoking like update xxx_table, it would be very straightforward, the whole transaction will rollback, but in a remote api invoking, I just can't rollback it. 如果调用paypal api是像update xxx_table一样调用的本地方法,那将非常简单,整个事务将回滚,但是在远程api调用中,我只是无法回滚。

Here comes the question, do we have a universal solutions for this case? 问题来了,我们是否有针对这种情况的通用解决方案?

Any suggestion would be appreciated. 任何建议,将不胜感激。

If the webservices are under your control you could use something like JBoss WS-Transactions or something similar, depending on your environment. 如果Web服务在您的控制之下,则可以根据环境使用类似JBoss WS-Transactions之类的东西。

When accessing third party webservices it depends on whether they provide a functionality like that, if not you'd have to do the rollback yourself. 访问第三方Web服务时,取决于它们是否提供这样的功能,否则,您必须自己进行回滚。

Besides that distributed transactions might cause more problems than they solve so you should carefully think about whether you really need them. 除此之外,分布式事务可能会导致问题超出解决的范围,因此您应仔细考虑是否真正需要它们。

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

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