public interface BaseConsumerContext
Note: ConsumerContext requires a pull consumer.
| Modifier and Type | Method and Description |
|---|---|
@NonNull MessageConsumer |
consume(@NonNull ConsumeOptions consumeOptions,
@Nullable Dispatcher dispatcher,
@NonNull MessageHandler handler)
Start a long-running MessageConsumer with custom ConsumeOptions.
|
@NonNull MessageConsumer |
consume(@NonNull ConsumeOptions consumeOptions,
@NonNull MessageHandler handler)
Start a long-running MessageConsumer with custom ConsumeOptions.
|
@NonNull MessageConsumer |
consume(@Nullable Dispatcher dispatcher,
@NonNull MessageHandler handler)
Start a long-running MessageConsumer with default ConsumeOptions.
|
@NonNull MessageConsumer |
consume(@NonNull MessageHandler handler)
Start a long-running MessageConsumer with default ConsumeOptions.
|
@NonNull FetchConsumer |
fetch(@NonNull FetchConsumeOptions fetchConsumeOptions)
Start a one-use Fetch Consumer with custom FetchConsumeOptions.
|
@NonNull FetchConsumer |
fetchBytes(int maxBytes)
Start a one use Fetch Consumer using all defaults other than the number of bytes.
|
@NonNull FetchConsumer |
fetchMessages(int maxMessages)
Start a one use Fetch Consumer using all defaults other than the number of messages.
|
@Nullable java.lang.String |
getConsumerName()
Gets the consumer name that was used to create the context.
|
@NonNull IterableConsumer |
iterate()
Start a long-running IterableConsumer with default ConsumeOptions.
|
@NonNull IterableConsumer |
iterate(@NonNull ConsumeOptions consumeOptions)
Start a long-running IterableConsumer with custom ConsumeOptions.
|
@Nullable Message |
next()
Read the next message with max wait set to ms
|
@Nullable Message |
next(@Nullable java.time.Duration maxWait)
Read the next message with provided max wait
|
@Nullable Message |
next(long maxWaitMillis)
Read the next message with provided max wait
|
boolean |
unpin(java.lang.String group)
Unpins this consumer
|
@Nullable java.lang.String getConsumerName()
@Nullable Message next() throws java.io.IOException, java.lang.InterruptedException, JetStreamStatusCheckedException, JetStreamApiException
java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionjava.lang.InterruptedException - if one is thrown, to propagate it upJetStreamStatusCheckedException - an exception representing a status that requires attention,
such as the consumer was deleted on the server in the middle of use.JetStreamApiException - the request had an error related to the data@Nullable Message next(@Nullable java.time.Duration maxWait) throws java.io.IOException, java.lang.InterruptedException, JetStreamStatusCheckedException, JetStreamApiException
maxWait - duration of max wait.
If null, zero or negative, will be used.
If greater than zero, it cannot be less than milliseconds.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionjava.lang.InterruptedException - if one is thrown, to propagate it upJetStreamStatusCheckedException - an exception representing a status that requires attention,
such as the consumer was deleted on the server in the middle of use.JetStreamApiException - the request had an error related to the datajava.lang.IllegalArgumentException - if maxWait is provided and less than @Nullable Message next(long maxWaitMillis) throws java.io.IOException, java.lang.InterruptedException, JetStreamStatusCheckedException, JetStreamApiException
maxWaitMillis - the max wait value in milliseconds. Cannot be less than milliseconds.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionjava.lang.InterruptedException - if one is thrown, to propagate it upJetStreamStatusCheckedException - an exception representing a status that requires attention,
such as the consumer was deleted on the server in the middle of use.JetStreamApiException - the request had an error related to the datajava.lang.IllegalArgumentException - if maxWait is provided and less than @NonNull FetchConsumer fetchMessages(int maxMessages) throws java.io.IOException, JetStreamApiException
FetchConsumermaxMessages - the maximum number of messages to consumejava.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull FetchConsumer fetchBytes(int maxBytes) throws java.io.IOException, JetStreamApiException
FetchConsumermaxBytes - the maximum number of bytes to consumejava.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull FetchConsumer fetch(@NonNull FetchConsumeOptions fetchConsumeOptions) throws java.io.IOException, JetStreamApiException
FetchConsumeOptionsfetchConsumeOptions - the custom fetch consume options.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull IterableConsumer iterate() throws java.io.IOException, JetStreamApiException
IterableConsumer and ConsumeOptions
IterableConsumer require the developer calls nextMessage.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull IterableConsumer iterate(@NonNull ConsumeOptions consumeOptions) throws java.io.IOException, JetStreamApiException
IterableConsumer and ConsumeOptions
IterableConsumer requires the developer calls nextMessage.consumeOptions - the custom consume optionsjava.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull MessageConsumer consume(@NonNull MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptions
and the default dispatcher for this consumer context.handler - the MessageHandler used for receiving messages.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull MessageConsumer consume(@Nullable Dispatcher dispatcher, @NonNull MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptionsdispatcher - The dispatcher to handle this subscription. If null, the default dispatcher will be used.handler - the MessageHandler used for receiving messages.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull MessageConsumer consume(@NonNull ConsumeOptions consumeOptions, @NonNull MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptions
and the default dispatcher for this consumer context.consumeOptions - the custom consume optionshandler - the MessageHandler used for receiving messages.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the data@NonNull MessageConsumer consume(@NonNull ConsumeOptions consumeOptions, @Nullable Dispatcher dispatcher, @NonNull MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptionsconsumeOptions - the custom consume optionsdispatcher - The dispatcher to handle this subscription. If null, the default dispatcher will be used.handler - the MessageHandler used for receiving messages.java.io.IOException - covers various communication issues with the NATS
server, such as timeout or interruptionJetStreamApiException - the request had an error related to the databoolean unpin(java.lang.String group)
throws java.io.IOException,
JetStreamApiException
group - the group name of the consumer's groupjava.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the data