Pulsar: Acknowledging list of messages in Pulsar consumer java client

Created on 22 Jul 2020  Â·  7Comments  Â·  Source: apache/pulsar

My project uses Apache pulsar for distributed messaging. While using the java consumer client I am facing an issue with acknowledgement of multiple messages in a single shot. The java consumer client as of now does not define any method for acknowledging a list of message ids.
I cannot use the cumulative acknowledge in this scenario – as the batch of messages that my consumer client receives requires an ordering based on few pre-defined message metadata – therefore the natural ordering of messages as received from broker is lost at the point where I am in a position to acknowledge the messages. Also looping through list of messages and sending acks per message is too much of a traffic overhead as in my use case I can expect 5000 messages per batch.
For scenarios like this, it would probably help to have a single non-blocking method call for a list of message ids – something similar to : CompletableFuture acknowledgeAsync(List> message);
My project uses Apache pulsar for distributed messaging. While using the java consumer client I am facing an issue with acknowledgement of multiple messages in a single shot. The java consumer client as of now does not define any method for acknowledging a list of message ids.
I cannot use the cumulative acknowledge in this scenario – as the batch of messages that my consumer client receives requires an ordering based on few pre-defined message metadata – therefore the natural ordering of messages as received from broker is lost at the point where I am in a position to acknowledge the messages. Also looping through list of messages and sending acks per message is too much of a traffic overhead as in my use case I can expect 5000 messages per batch.
For scenarios like this, it would probably help to have a single non-blocking method call for a list of message ids – something similar to : CompletableFuture acknowledgeAsync(List> message);

componenclient help wanted triagweek-30 typfeature

All 7 comments

Thanks, @pg2404 There was already a simlar interface : "CompletableFuture acknowledgeAsync(Messages messages)".
If this is not enough for your use case, It should be not hard to turn it into the interface that you want.

Please assign it to me

@jiazhai - Thanks for the prompt reply. I am looking at http://pulsar.apache.org/api/client/2.2.0/org/apache/pulsar/client/impl/ConsumerBase.html for documentation of the interface you mentioned - but unfortunately I could not find any further information on the usage of the API - for instance how to build the Messages object / if it is similar to java Collection. Can you please point me to any documentation on this interface?

@pg2404 Could you please take a look matteo's comment https://github.com/apache/pulsar/pull/7688#issuecomment-665843163?

Thanks @codelipenghui - just did and replied on that thread.

Hi @315157973 @codelipenghui -are the changes available in 2.6.0 ?

@pg2404 2.6.0 has released before creating this issue, so we can't onboard it in 2.6.0.

Was this page helpful?
0 / 5 - 0 ratings