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 Details

    • receive

      Receive a single message asynchronously.
      Returns:
      a CompletableFuture that completes with the next available message
    • receive

      CompletableFuture<Message<T>> receive(Duration timeout)
      Receive a single message, completing with null if the timeout elapses without a message becoming available.
      Parameters:
      timeout - the maximum duration to wait for a message
      Returns:
      a CompletableFuture that completes with the next available message, or null if the timeout elapses
    • receiveMulti

      CompletableFuture<List<Message<T>>> receiveMulti(int maxNumMessages, Duration timeout)
      Receive a batch of messages asynchronously.
      Parameters:
      maxNumMessages - maximum number of messages to return
      timeout - maximum time to wait for messages
      Returns:
      a CompletableFuture that completes with a list of up to maxNumMessages messages
    • acknowledgeCumulative

      void acknowledgeCumulative(MessageId messageId)
      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

      void acknowledgeCumulative(MessageId messageId, Transaction txn)
      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

      Close this consumer asynchronously.
      Returns:
      a CompletableFuture that completes when the consumer has been closed and all resources have been released