You can use the graceful shutdown feature of ApsaraMQ for RocketMQ to effectively prevent message loss and other issues caused by sudden client disconnections. This helps ensure business continuity and availability.
Feature overview
Graceful shutdown is a core feature introduced by ApsaraMQ for RocketMQ to improve broker reliability in O&M scenarios. With multiple protection mechanisms, the feature can be used to prevent issues caused by sudden client disconnections, such as client errors and message loss, helping ensure business continuity and availability.
Protection mechanisms
Prohibition of write operations to nodes
Before restarting a storage node, the broker temporarily prohibits write operations to it until no new messages are written to it. This ensures that messages already sent from clients are properly stored.
Connection closure
ApsaraMQ for RocketMQ brokers use the GOAWAY frame defined in HTTP/2 to initiate graceful shutdown of connections or notify clients of impending connection closures. This mechanism helps coordinate between brokers and clients during connection termination, preventing incomplete requests from being suddenly interrupted and ensuring system stability.
Effects
Producer: All requests submitted by producers are successfully processed.
Consumer:
Most messages are successfully consumed.
In rare cases, a small number of messages accumulated on storage nodes that are being restarted are redelivered due to offset commitment failures.
Requirements on client versions
To ensure normal use of graceful shutdown, client SDKs must meet the following version requirements.
Programming language | Minimum supported version | References |
Java (gRPC protocol) | 5.0.7 | |
Java (Remoting protocol) | 5.3.1 | |
Go | 5.1.0-rc.1 | |
Python | 5.0.4 | |
C++ | 5.0.2 | |
C# | 5.1.0 |