Java-Interview-Advanced/docs/distributed-system/eventual-consistency.md
2020-04-25 19:55:58 +08:00

9 lines
774 B
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

其实也很简单自己写一个可靠消息服务即可接收人家发送的half message然后返回响应给人家如果Producer没收到响应则重发。然后Producer执行本地事务接着发送commit/rollback给可靠消息服务。
可靠消息服务启动一个后台线程定时扫描本地数据库表中所有half message超过一定时间没commit/rollback就回调Producer接口确认本地事务是否成功获取commit/rollback
如果消息被rollback就废弃掉如果消息被commit就发送这个消息给下游服务或者是发送给RabbitMQ/Kafka/ActiveMQ都可以然后下游服务消费了必须回调可靠消息服务接口进行ack
如果一段时间都没收到ack则重发消息给下游服务