Interface AckReplyConsumerWithResponse

All Known Implementing Classes:
AckReplyConsumerWithResponseImpl

@BetaApi("This is a preview feature. For more details, see https://cloud.google.com/pubsub/docs/exactly-once-delivery.") 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.

  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.api.core.ApiFuture<AckResponse>
    ack()
    Acknowledges that the message has been successfully processed.
    com.google.api.core.ApiFuture<AckResponse>
    Signals that the message has not been successfully processed.
  • Method Details

    • ack

      com.google.api.core.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

    • nack

      com.google.api.core.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