Skip to content

Batch acknowledgement is not working in asynchronous call #3257

Description

@anamika-papajohns

We are having the requirement of creating a batch of messages on every one minute.
Once batch is processed and return success in response, we need to acknowledge all the messages which were present in that batch.
If batch process response is failure , we need to unacknowledged the messages.

Current functionality given by pub/sub library: In asynchronous call, we can ack/nack message one by one, immediate after receiving.

Below is our code snippet-

Subscriber.Builder builder = Subscriber.newBuilder(subscription, new MessageReceiver() {
                @Override
                public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
                    // handle incoming message, then ack/nack the received message
              try {                             
                       //dropping the message in a queue
                      //here we are creating a batch on every one minute and ack/nack the message accordingly
                                
                     }

also do we have any method to get ackId instead of MessageId in case of asynchronous call.

Activity

  1. added
    type: questionRequest for information or clarification. Not an issue.
    api: pubsubIssues related to the Pub/Sub API.
    on May 18, 2018
  2. pongad commented on May 21, 2018

    @pongad
    Contributor

    @anamika-papajohns Let's see if I understand this right:

    You want to pull many messages, process all of them, and either ack or nack all messages you pulled, is this right?

    I don't think this use case is well-supported by pubsub. The reason is that pubsub guarantees "at least 1 delivery". If you ack 10 messages, sometimes some of the acks will be lost and some messages will get redelivered.

    Is it possible to, for example, pack "sub-messages" into one pubsub message?

  3. self-assigned this
    on May 21, 2018
  4. removed their assignment
    on Jun 4, 2018
  5. self-assigned this
    on Jun 5, 2018
  6. yihanzhen commented on Jun 13, 2018

    @yihanzhen
    Contributor

    It seems the problem is solved here. Please ask for reopening if not.

  7. added a commit that references this issue on Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: pubsubIssues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions