Description
The consumer currently sends the ACK command to the broker but does not wait for or validate the corresponding ACK_RESPONSE.
As a result, the client may consider a message successfully acknowledged even when the broker did not process the acknowledgment.
Reproduction scenario
- Receive a message from Pulsar.
- Stop the Pulsar broker gracefully before acknowledging the message.
- Call the consumer acknowledgment method.
- The client writes the
ACK command but does not verify that the broker returned an ACK_RESPONSE.
- The acknowledgment method may complete successfully even though the message was not acknowledged.
In my test, waiting for a response after sending the command exposed broker responses such as CLOSE_CONSUMER.
Actual behavior
The client only writes the acknowledgment command to the socket. A successful socket write confirms that the bytes were accepted by the local socket, but it does not confirm that the Pulsar broker received or processed the acknowledgment.
This can cause the application to log or treat a message as acknowledged while Pulsar still considers it unacknowledged, resulting in message redelivery.
Expected behavior
After sending an ACK command, the client should:
- Include a request ID in the command.
- Wait for the corresponding
ACK_RESPONSE.
- Queue any
MESSAGE commands received while waiting, so they can be processed later.
- Handle unrelated commands, including responding to
PING and ignoring PONG.
- Handle
CLOSE_CONSUMER appropriately.
- Match the
ACK_RESPONSE using its request ID.
- Throw an exception if:
- the broker rejects the acknowledgment;
- the connection is closed;
- no matching response is received before the client’s configured timeout.
The acknowledgment method should only return successfully after the matching ACK_RESPONSE has been received and validated.
Description
The consumer currently sends the
ACKcommand to the broker but does not wait for or validate the correspondingACK_RESPONSE.As a result, the client may consider a message successfully acknowledged even when the broker did not process the acknowledgment.
Reproduction scenario
ACKcommand but does not verify that the broker returned anACK_RESPONSE.In my test, waiting for a response after sending the command exposed broker responses such as
CLOSE_CONSUMER.Actual behavior
The client only writes the acknowledgment command to the socket. A successful socket write confirms that the bytes were accepted by the local socket, but it does not confirm that the Pulsar broker received or processed the acknowledgment.
This can cause the application to log or treat a message as acknowledged while Pulsar still considers it unacknowledged, resulting in message redelivery.
Expected behavior
After sending an
ACKcommand, the client should:ACK_RESPONSE.MESSAGEcommands received while waiting, so they can be processed later.PINGand ignoringPONG.CLOSE_CONSUMERappropriately.ACK_RESPONSEusing its request ID.The acknowledgment method should only return successfully after the matching
ACK_RESPONSEhas been received and validated.