Giter VIP home page Giter VIP logo

Comments (1)

unixliang avatar unixliang commented on September 1, 2024

您好,
支付确实需要exactly-once,但是队列在整个支付流程中只是其中一个系统,即使队列完全实现了exactly-once,其它系统也要考虑幂等。既然业务本身需要考虑幂等,队列是at-least-once还是exactly-once就区别不大了。
据我了解,一个消息队列要做到exactly-once,也是要与业务一起配合的,需要做到如下两点:

  1. Producer生产支持幂等,这个容易实现;
  2. Consumer消费时对业务所做的状态变更,需要与偏移的更新保持同步;Kafka提出了以下两种做法:
    2.1. 队列保存业务状态与偏移,保证两者的写是一个原子操作;如果consumer重启了,就取出偏移,作为消费开始位置;这里需要保存在同一个DB里,否则就变成了一个分布式事务,分布式事务的实现依赖队列,变成了先有鸡还是先有蛋的问题;
    2.2. 业务保存业务状态与偏移,并提供幂等特性,忽略任何偏移值比存储偏移值小的写入。

from phxqueue.

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.