duhengforever commented on issue #292: RocketMQ Feature Request: 
Transaction-Aware Message
URL: https://github.com/apache/rocketmq/issues/292#issuecomment-394414833
 
 
   Thanks for @lizhanhui's feature request,and as mentioned above, with the 
rise of micro service architecture,developers are eager to use a mechanism to 
ensure the eventual consistency of transaction, especially in distributed 
systems, and we also found transaction aware message can achieve this goal 
gracefully, so we intend to implement this feature in rocketMQ, and this 
process is as follows:
   
   
   
![transaction](https://user-images.githubusercontent.com/39583243/40928949-a6e0b728-6855-11e8-863e-f69faa80e4f5.png)
   
   
   
   
   In our design, we will define a pair of message: named half message and 
commit/rollback message. As mentioned by @lizhanhui, half message means 
prepared message, which are not visible to consumers,and it will be sent before 
local transaction is executed. After the local transaction ends,producer will 
send a commit or rollback message  to broker based on local transaction 
execution result. when producers are blocked or crashed after send a half 
message,the broker will check all of producers with the same role to obtain the 
transaction status, so producer must implement the check listener interface to 
response transaction check query request.
   
   
   In our implementation, we will make full use of the mechanism of rocketMQ 
itself to avoid external dependencies, so we will build two new system topic to 
store half message(RMQ_SYS_TRANS_HALF_TOPIC)and commit/rollback result 
message(RMQ_SYS_TRANS_OP_HALF_TOPIC),and we will also add a checkback service 
in broker to periodically check every message in the half message queue, if its 
corresponding result message can be found in the result message queue, it will 
be consumed or discarded depends on its result status,and if this message 
cannot be found in the result queue,that indicates that it was in pending 
status, so the checkback service will send check request to all corresponding 
producers to obtain transaction status, at the same time,we will also support 
immunity time config for producer to avoid being checked prematurely, the 
pending status but still in immunity time message will be reload to the half 
message queue to wait for the next round of check.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to