Interface AckReplyConsumerWithResponse (1.133.0)

public interface AckReplyConsumerWithResponse

Acknowledging a message in Pub/Sub means that you are done with it, and it will not be delivered to this subscription again. You should avoid acknowledging messages until you have finished processing them, so that in the event of a failure, you receive the message again.

If exactly-once delivery is enabled on the subscription, the future returned by the ack/nack methods track the state of acknowledgement operation by the server. If the future completes successfully, the message is guaranteed NOT to be re-delivered. Otherwise, the future will contain an exception with more details about the failure and the message may be re-delivered.

If exactly-once delivery is NOT enabled on the subscription, the future returns immediately with an AckResponse.SUCCESS. Because re-deliveries are possible, you should ensure that your processing code is idempotent, as you may receive any given message more than once.

Methods

ack()

public abstract ApiFuture<AckResponse> ack()

Acknowledges that the message has been successfully processed. The service will not send the message again.

A future representing the server response is returned

Returns
Type Description
ApiFuture<AckResponse>

nack()

public abstract ApiFuture<AckResponse> nack()

Signals that the message has not been successfully processed. The service should resend the message.

A future representing the server response is returned

Returns
Type Description
ApiFuture<AckResponse>