6U-U9 commented on PR #4428: URL: https://github.com/apache/rocketmq/pull/4428#issuecomment-1153232642
> `org.apache.rocketmq.broker.transaction.queue.DefaultTransactionalMessageCheckListener#resolveDiscardMsg` handles transactional messages that should not be processed any more, what about normal transactional messages on the slave broker in acting master mode? Furthermore, what happened if the broken master recovered? When dealing with transaction message normally, **transactionalMessageCheckService** checks half messages in **RMQ_SYS_TRANS_HALF_TOPIC**, calls **putBackHalfMsgQueue** to rewrite messages still need to check back to message queue of **RMQ_SYS_TRANS_HALF_TOPIC** , and updates consume offset. When slave acts master, its **transactionalMessageCheckService** will start, but its **EndTransactionProcessor** will not accept any message tries to end a transaction such as commit or rollback. The running **transactionalMessageCheckService** will check transaction message and send any message needs check to a living master. **RMQ_SYS_TRANS_HALF_TOPIC** is also a topic not allowed to send in topic validator.So first wrap them in their origin topic with transaction check time, and send it to other master broker. Messages will bring its properties, such as **PROPERTY_TRANSACTION_CHECK_TIMES** , so master broker received these message is not going to check the transaction message for another **TRANS_CHECK_MAX_TIME**. When the master broker recovers, it will be in pre-online progress before it is launched. It reversely obtains the metadata of the slave, especially the consumer offset of **RMQ_SYS_TRANS_HALF_TOPIC**. Thus the recovered master broker will not check the message which has escaped. 在正常处理事务消息时,**transactionalMessageCheckService**检查半消息队列**RMQ_SYS_TRANS_HALF_TOPIC**中的半消息,并调用**putBackHalfMsgQueue**将检查到的并且仍需进行检查的消息写入半消息队列**RMQ_SYS_TRANS_HALF_TOPIC**中,并更新消费位置。 Slave代理Master时,**transactionalMessageCheckService**将启动。**transactionalMessageCheckService**将检查到的事务消息通过EscapeBridge向其他的Master逃逸。逃逸过程中为了避免半消息**RMQ_SYS_TRANS_HALF_TOPIC**不可写的限制,首先将半消息用原Topic包装,此时消息仍携带**PROPERTY_TRANSACTION_CHECK_TIMES**等属性,然后再投递到远程主节点上。收到消息的主节点将消息放入半消息队列**RMQ_SYS_TRANS_HALF_TOPIC**等待检查。 在主节点恢复后,通过预上线机制获取从节点的**RMQ_SYS_TRANS_HALF_TOPIC**队列的消费位点,更新主节点自己的**RMQ_SYS_TRANS_HALF_TOPIC**队列的消费位点,将不再检查已经逃逸的事务消息。 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
