KubeMQ client 實作、定義通用 event models 及 sender & receiver 抽象介面
Implement base on:
- Outbox https://microservices.io/patterns/data/transactional-outbox.html
- Polling-publisher https://microservices.io/patterns/data/polling-publisher.html
Notify the polling publisher there are new messages in outbox.
- Wait for sender call.
- Enable.
- Send notification to polling publisher.
- If get error response, retry 2. till success.
- Disable. (if there's any new message added during enable time, it won't cause extra notification.)
Save message in outbox, and call notifier (Implement base on one context per request)
- New sender per context.
- store the message in outbox. (if not in transaction, call notifier)
- call notifier after transaction commit.
Save message in inbox, and call the handler.
- get message from MQ.
- save to inbox. (should send an ACK to MQ)
- call service to handle it.
- service pick up the top message from inbox and process the message.
- if not success, wait a second, then try again.
- after 3 times failure, put message in the hospital. // should have another flow to fix these message
- if success, delete the message from inbox.
- go back to step 3. till the inbox is empty.