Giter VIP home page Giter VIP logo

Comments (6)

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

Thank you for your feedback, we will evaluate the question whether included in the plan.

from cap.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

@alexinea @liuhaoyang

我们评估一下这个需不需要支持吧?

我描述一下情况: 这个就是针对于发送方在发送一条消息,消费者在消费的时候出现“业务”失败(比如库存不够),然后需要通知生产方。

目前针对于这种的处理办法是,消费者在处理业务的时候,如果库存不够需要消费者那边手动发送一条“库存不足”的消息通知生产者这边来处理接下来的业务。

这个issue的意思是:CAP在订阅那里提供一种失败回调的方法,然后在订阅的时候可以[CabSubscribe("",CallBack="")],然后碰到失败的情况时候,可以比如抛出一种 ServiceFailedException(data) 这种异常。

在实现上,针对这种这种异常情况,CAP在MQ测提供一个单独的通道,用来处理这种业务,CAP当接收到这种消息的时候,会进行路由到具体的回滚方法上。

from cap.

alexinea avatar alexinea commented on July 21, 2024

@yuleyule66 Xieyao.

I think this feature should be implemented in CAP.Server, not in the CAP any more.

from cap.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

@alexinea 今天在看 ENode 架构图的时候突然瞄到了 Saga,我觉得可以完美解释这个 issue。

saga这个术语,可能很多人都还很陌生。saga的提出,最早是为了解决可能会长时间运行的分布式事务(long-running process)的问题。所谓long-running的分布式事务,是指那些企业业务流程,需要跨应用、跨企业来完成某个事务,甚至在事务流程中还需要有手工操作的参与,这类事务的完成时间可能以分计,以小时计,甚至可能以天计。这类事务如果按照事务的ACID的要求去设计,势必造成系统的可用性大大的降低。试想一个由两台服务器一起参与的事务,服务器A发起事务,服务器B参与事务,B的事务需要人工参与,所以处理时间可能很长。如果按照ACID的原则,要保持事务的隔离性、一致性,服务器A中发起的事务中使用到的事务资源将会被锁定,不允许其他应用访问到事务过程中的中间结果,直到整个事务被提交或者回滚。这就造成事务A中的资源被长时间锁定,系统的可用性将不可接受。
而saga,则是一种基于补偿的消息驱动的用于解决long-running process的一种解决方案。目标是为了在确保系统高可用的前提下尽量确保数据的一致性。还是上面的例子,如果用saga来实现,那就是这样的流程:服务器A的事务先执行,如果执行顺利,那么事务A就先行提交;如果提交成功,那么就开始执行事务B,如果事务B也执行顺利,则事务B也提交,整个事务就算完成。但是如果事务B执行失败,那事务B本身需要回滚,这时因为事务A已经提交,所以需要执行一个补偿操作,将已经提交的事务A执行的操作作反操作,恢复到未执行前事务A的状态。这样的基于消息驱动的实现思路,就是saga。我们可以看出,saga是牺牲了数据的强一致性,仅仅实现了最终一致性,但是提高了系统整体的可用性。
以上,引用自 http://www.cnblogs.com/netfocus/p/3149156.html

from cap.

yang-xiaodong avatar yang-xiaodong commented on July 21, 2024

I have added a method overloaded parameter with callbackName in the ICapPublisher , now you can assigned a call back subscribe name when publish a message to CAP.

The call back subscribe method will received consumer method returned value.

You can use this feature at preview version now.

from cap.

CleanCoder avatar CleanCoder commented on July 21, 2024

[CabSubscribe("",CallBack="")], Callback调用时机是有问题的。目前CAP我觉得只适合A -> B的场景。
想象下 A -> B -> C的时候 该怎么办呢? B给A的回调,必须要等C给B回调才能触发 , 而看CAP的代码,B方法退出时就发出了CallBack,根本没有等到C的结束。
假设C失败了,发出回滚事件能正常回滚B再回滚A吗? 我的答案是否定的

from cap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.