Overview
Last updated
Was this helpful?
Last updated
Was this helpful?
Defer processing of time-consuming tasks without blocking our clients. Anything that is slow or unpredictable is a candidate for asynchronous processing. Example include
Interact with remote servers
Low-value processing in the critical path
Resource intensive work
Independent processing of high- and low- priority jobs
For example, in flash sale scenarios. Fast operations (deduct inventory number inside cache) could be performed in real time while slow operations (Whether the user has participated in flash sale before, deduct inventory number inside DB) could be put inside a queue.
How hard it is when you want to add a new downstream partner
With message queue, the downstream only needs to know the topic to subscribe.
With RPC/REST, downstream needs to know the server address and protocol format.
Even if some downstream partners fail, the service don't need to retry, etc.
Otherwise, it needs to guarantee the communication with downstream goes smoothly.
Enterprise integration patterns: https://www.enterpriseintegrationpatterns.com/index.html
https://zhuanlan.zhihu.com/p/59000202
https://zhuanlan.zhihu.com/p/64901908
Reliable message producing
Data needs to be persisted
Confirmation needs to be obtained
Producer needs to retry
Reliable message consumption
Ack mechanism
Please see this