public interface BaseConsumerContext
Note: ConsumerContext requires a pull consumer.
| Modifier and Type | Method and Description |
|---|---|
MessageConsumer |
consume(ConsumeOptions consumeOptions,
Dispatcher dispatcher,
MessageHandler handler)
Start a long-running MessageConsumer with custom ConsumeOptions.
|
MessageConsumer |
consume(ConsumeOptions consumeOptions,
MessageHandler handler)
Start a long-running MessageConsumer with custom ConsumeOptions.
|
MessageConsumer |
consume(Dispatcher dispatcher,
MessageHandler handler)
Start a long-running MessageConsumer with default ConsumeOptions.
|
MessageConsumer |
consume(MessageHandler handler)
Start a long-running MessageConsumer with default ConsumeOptions.
|
FetchConsumer |
fetch(FetchConsumeOptions fetchConsumeOptions)
Start a one use Fetch Consumer with complete custom consume options.
|
FetchConsumer |
fetchBytes(int maxBytes)
Start a one use Fetch Consumer using all defaults other than the number of bytes.
|
FetchConsumer |
fetchMessages(int maxMessages)
Start a one use Fetch Consumer using all defaults other than the number of messages.
|
java.lang.String |
getConsumerName()
Gets the consumer name that was used to create the context.
|
IterableConsumer |
iterate()
Start a long-running IterableConsumer with default ConsumeOptions.
|
IterableConsumer |
iterate(ConsumeOptions consumeOptions)
Start a long-running IterableConsumer with custom ConsumeOptions.
|
Message |
next()
Read the next message with max wait set to ms
|
Message |
next(java.time.Duration maxWait)
Read the next message with provided max wait
|
Message |
next(long maxWaitMillis)
Read the next message with provided max wait
|
java.lang.String getConsumerName()
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, in order 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 dataMessage next(java.time.Duration maxWait) throws java.io.IOException, java.lang.InterruptedException, JetStreamStatusCheckedException, JetStreamApiException
maxWait - duration of max wait. 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, in order 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 dataMessage 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, in order 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 dataFetchConsumer fetchMessages(int maxMessages) throws java.io.IOException, JetStreamApiException
FetchConsumermaxMessages - the maximum number of message 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 dataFetchConsumer 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 dataFetchConsumer fetch(FetchConsumeOptions fetchConsumeOptions) throws java.io.IOException, JetStreamApiException
FetchConsumerfetchConsumeOptions - the custom fetch consume options. See FetchConsumeOptionsjava.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the dataIterableConsumer iterate() throws java.io.IOException, JetStreamApiException
IterableConsumer and ConsumeOptions
IterableConsumer require the developer call 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 dataIterableConsumer iterate(ConsumeOptions consumeOptions) throws java.io.IOException, JetStreamApiException
IterableConsumer and ConsumeOptions
IterableConsumer requires the developer call 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 dataMessageConsumer consume(MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptionshandler - 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 dataMessageConsumer consume(Dispatcher dispatcher, MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptionsdispatcher - The dispatcher to handle this subscriptionhandler - 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 dataMessageConsumer consume(ConsumeOptions consumeOptions, MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptionsconsumeOptions - 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 dataMessageConsumer consume(ConsumeOptions consumeOptions, Dispatcher dispatcher, MessageHandler handler) throws java.io.IOException, JetStreamApiException
MessageConsumer and ConsumeOptionsconsumeOptions - the custom consume optionsdispatcher - The dispatcher to handle this subscriptionhandler - 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