Interface AsyncStreamConsumer<T>
- Type Parameters:
T- the type of message values
public interface AsyncStreamConsumer<T>
Asynchronous view of a
StreamConsumer.
All operations return CompletableFuture and never block.
Obtained via StreamConsumer.async().
-
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledgeCumulative(MessageId messageId) Acknowledge all messages up to and including the given message ID.voidacknowledgeCumulative(MessageId messageId, Transaction txn) Acknowledge within a transaction.close()Close this consumer asynchronously.receive()Receive a single message asynchronously.Receive a single message, completing withnullif the timeout elapses without a message becoming available.receiveMulti(int maxNumMessages, Duration timeout) Receive a batch of messages asynchronously.
-
Method Details
-
receive
CompletableFuture<Message<T>> receive()Receive a single message asynchronously.- Returns:
- a
CompletableFuturethat completes with the next available message
-
receive
Receive a single message, completing withnullif the timeout elapses without a message becoming available.- Parameters:
timeout- the maximum duration to wait for a message- Returns:
- a
CompletableFuturethat completes with the next available message, ornullif the timeout elapses
-
receiveMulti
Receive a batch of messages asynchronously.- Parameters:
maxNumMessages- maximum number of messages to returntimeout- maximum time to wait for messages- Returns:
- a
CompletableFuturethat completes with a list of up tomaxNumMessagesmessages
-
acknowledgeCumulative
Acknowledge all messages up to and including the given message ID.- Parameters:
messageId- the message ID up to which all messages are acknowledged (inclusive)
-
acknowledgeCumulative
Acknowledge within a transaction. The acknowledgment becomes effective when the transaction is committed.- Parameters:
messageId- the message ID up to which all messages are acknowledged (inclusive)txn- the transaction to associate this acknowledgment with
-
close
CompletableFuture<Void> close()Close this consumer asynchronously.- Returns:
- a
CompletableFuturethat completes when the consumer has been closed and all resources have been released
-