Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the transaction message for RocketMq?

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what is the transaction message of RocketMq". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Introduction to the concept of transaction message

Half (Prepare) Message

The message cannot be delivered. When the message is successfully sent to Broker, Broker does not receive a second acknowledgement event from Producer, and the message is marked by broker as temporarily undispatched. The message in this state is Half (Prepare) Message.

Message status check

Network disconnection and restart of Productor application service will lead to the loss of transaction message secondary acknowledgement event. When broker finds that the message has been in the state of Half (Prepare) Message, it will send a request to the Productor application to confirm the final status of the message (dispatch or rollback).

Transaction message execution process:

1.Producer sends Half (Prepare) Message to Broker

two。 Send Half (Prepare) Message success to execute local transaction

3. Send commit or rollback messages to Broker based on the results of local transaction execution

4. If the commit or rollback message is lost or if the Producer is suspended during a local transaction, Broker sends a check message to all producer of the same set of classes to confirm the final state of the transaction

5.Producer replies to commit / rollback messages based on the status of the local transaction

6. The submitted message will be delivered to the subscribed Consumer, but the Broker server will discard the rolled back message

Detailed design

In order to abstract the underlying implementation of storage, Rocketmq centralizes all transactional message operations on the transaction service interface. RocketMQ provides a default implementation with its own storage system, and we use transaction bridges to implement our transaction storage logic, rather than directly modifying the storage layer of RocketMQ.

Send transaction messages

The sequence diagram of sending transaction messages and how the transaction messages are committed in two phases.

Transaction message check

The transaction message verification logic sequence diagram shows that if the transaction message has been in Half (Prepare) Message status,Broker, an acknowledgement message is sent to producer to verify the final state of the transaction message.

This is the end of the content of "what is the transaction message of RocketMq". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report