Interface MessageAcknowledger
- All Known Subinterfaces:
Consumer<T>
It contains two methods of various overloads: - `acknowledge`: acknowledge individually - `acknowledgeCumulative`: acknowledge cumulatively Each of them has an associated asynchronous API that has the "Async" suffix in the name.
The 1st method parameter is
- MessageId
or Message
when acknowledging a single message
- List<MessageId>
or Messages
when acknowledging multiple messages
The 2nd method parameter is optional. Specify a non-null Transaction
instance for transaction usages:
- After the transaction is committed, the message will be actually acknowledged (individually or cumulatively).
- After the transaction is aborted, the message will be redelivered.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
acknowledge
(List<MessageId> messageIdList) Acknowledge the consumption of a list of message.default void
acknowledge
(Message<?> message) void
acknowledge
(MessageId messageId) Acknowledge the consumption of a single message.default void
acknowledge
(Messages<?> messages) acknowledgeAsync
(List<MessageId> messageIdList) The asynchronous version ofacknowledge(List)
.acknowledgeAsync
(List<MessageId> messageIdList, Transaction txn) The asynchronous version ofacknowledge(List)
with transaction support.acknowledgeAsync
(Message<?> message) The asynchronous version ofacknowledge(Message)
.default CompletableFuture<Void>
acknowledgeAsync
(MessageId messageId) The asynchronous version ofacknowledge(MessageId)
.acknowledgeAsync
(MessageId messageId, Transaction txn) The asynchronous version ofacknowledge(MessageId)
with transaction support.acknowledgeAsync
(Messages<?> messages) The asynchronous version ofacknowledge(Messages)
.acknowledgeAsync
(Messages<?> messages, Transaction txn) The asynchronous version ofacknowledge(Messages)
with transaction support.default void
acknowledgeCumulative
(Message<?> message) void
acknowledgeCumulative
(MessageId messageId) Acknowledge the reception of all the messages in the stream up to (and including) the provided message.default CompletableFuture<Void>
acknowledgeCumulativeAsync
(Message<?> message) The asynchronous version ofacknowledgeCumulative(Message)
.default CompletableFuture<Void>
acknowledgeCumulativeAsync
(MessageId messageId) The asynchronous version ofacknowledgeCumulative(MessageId)
.acknowledgeCumulativeAsync
(MessageId messageId, Transaction txn) The asynchronous version ofacknowledgeCumulative(MessageId)
with transaction support.
-
Method Details
-
acknowledge
Acknowledge the consumption of a single message.- Parameters:
messageId
-MessageId
to be individual acknowledged- Throws:
PulsarClientException.AlreadyClosedException
- } if the consumer was already closedPulsarClientException.NotAllowedException
- if `messageId` is not aTopicMessageId
when multiple topics are subscribedPulsarClientException
-
acknowledge
- Throws:
PulsarClientException
-
acknowledge
Acknowledge the consumption of a list of message.- Parameters:
messageIdList
- the list of message IDs.- Throws:
PulsarClientException.NotAllowedException
- if any message id in the list is not aTopicMessageId
when multiple topics are subscribedPulsarClientException
-
acknowledge
- Throws:
PulsarClientException
-
acknowledgeCumulative
Acknowledge the reception of all the messages in the stream up to (and including) the provided message.This method will block until the acknowledge has been sent to the broker. After that, the messages will not be re-delivered to this consumer.
Cumulative acknowledge cannot be used when the consumer type is set to ConsumerShared.
It's equivalent to calling asyncAcknowledgeCumulative(MessageId) and waiting for the callback to be triggered.
- Parameters:
messageId
- TheMessageId
to be cumulatively acknowledged- Throws:
PulsarClientException.AlreadyClosedException
- if the consumer was already closedPulsarClientException.NotAllowedException
- if `messageId` is not aTopicMessageId
when multiple topics are subscribedPulsarClientException
-
acknowledgeCumulative
- Throws:
PulsarClientException
-
acknowledgeAsync
The asynchronous version ofacknowledge(MessageId)
with transaction support. -
acknowledgeAsync
The asynchronous version ofacknowledge(MessageId)
. -
acknowledgeAsync
The asynchronous version ofacknowledge(List)
with transaction support. -
acknowledgeAsync
The asynchronous version ofacknowledge(List)
. -
acknowledgeAsync
The asynchronous version ofacknowledge(Message)
. -
acknowledgeAsync
The asynchronous version ofacknowledge(Messages)
. -
acknowledgeAsync
The asynchronous version ofacknowledge(Messages)
with transaction support. -
acknowledgeCumulativeAsync
The asynchronous version ofacknowledgeCumulative(MessageId)
with transaction support.- Parameters:
messageId
- TheMessageId
to be cumulatively acknowledgedtxn
-Transaction
the transaction to cumulative ack
-
acknowledgeCumulativeAsync
The asynchronous version ofacknowledgeCumulative(Message)
. -
acknowledgeCumulativeAsync
The asynchronous version ofacknowledgeCumulative(MessageId)
.
-