Skip to content

Commit

Permalink
Improve code by TSG
Browse files Browse the repository at this point in the history
  • Loading branch information
liuh-80 committed Apr 17, 2023
1 parent dda7933 commit 46779e4
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# 1 Functional Requirement
## 1.1 ZMQ client supported operations
- ZmqClient will send message to ZMQ.
- ZmqClient can reuse by multiple ZmqProducerStateTable instance.
- ZmqClient can be reused by multiple ZmqProducerStateTable instance.
- ZmqClient sendMsg() method is thread safe async method, will return immediately, ZMQ lib support async operation.
- ZmqClient will retry when send not success:
- When ZMQ socket connection broken, send API will failed and need re-connect and send again.
Expand All @@ -25,7 +25,7 @@
- ZmqClient will throw exception when ZMQ connection break.
## 1.2 ZMQ server supported operations
- ZmqServer will start a receive thread and receive message from ZMQ.
- ZmqServer can reuse by multiple ZmqConsumerStateTable instance.
- ZmqServer can be reused by multiple ZmqConsumerStateTable instance.
- When ZmqServer receive message from ZMQ, ZmqServer will:
- De-serialize received message.
- Find ZmqMessageHandler by message content.
Expand Down Expand Up @@ -55,20 +55,26 @@
- After send notification, continue receive next message from ZMQ.

# 2 Design

- Diagram:
<img src="./zmq-diagram.png" style="zoom:100%;" />

- Sequence:
<img src="./zmq-sequence.png" style="zoom:100%;" />

- Call ZmqProducerStateTable API.
- ZmqProducerStateTable will send message with ZmqClient.
- ZmqClient will serialize operation and send to ZMQ.
- ZmqClient will add database name and table name to message for ZmqServer side message dispatch.
- Return when send success.
- Retry when send failed.
- Throw exception when retry failed.
- ZmqServer Side:
- m_mqPollThread:
- Receive message from ZMQ.
- De-serialize received message then dispatch message to ZmqConsumerStateTable.
- ZmqServer manage a database name & table name to ZmqConsumerStateTable mapping. ZmqConsumerStateTable will register itself to this mapping.
- ZmqServer will find ZmqConsumerStateTable by database name and table name.
- Continue receive next message.
- ZmqConsumerStateTable Side:
- Receive message from ZmqServer then:
Expand Down

0 comments on commit 46779e4

Please sign in to comment.