public interface JetStreamSubscription extends Subscription
Modifier and Type | Field and Description |
---|---|
static int |
MAX_PULL_SIZE
The maximum pull size
|
DEFAULT_MAX_BYTES, DEFAULT_MAX_MESSAGES
Modifier and Type | Method and Description |
---|---|
java.util.List<Message> |
fetch(int batchSize,
java.time.Duration maxWait)
Fetch a list of messages up to the batch size, waiting no longer than maxWait.
|
ConsumerInfo |
getConsumerInfo()
Gets information about the consumer behind this subscription.
|
java.util.Iterator<Message> |
iterate(int batchSize,
java.time.Duration maxWait)
Prepares an iterator.
|
void |
pull(int batchSize)
Polls for new messages, overriding the default batch size for this pull only.
|
void |
pullExpiresIn(int batchSize,
java.time.Duration expiresIn)
Initiate pull for all messages available before expiration.
|
void |
pullNoWait(int batchSize)
Do a pull in noWait mode with the specified batch size.
|
getDispatcher, getQueueName, getSubject, nextMessage, unsubscribe, unsubscribe
clearDroppedCount, drain, getDeliveredCount, getDroppedCount, getPendingByteCount, getPendingByteLimit, getPendingMessageCount, getPendingMessageLimit, isActive, setPendingLimits
static final int MAX_PULL_SIZE
void pull(int batchSize)
batchSize
- the size of the batchvoid pullNoWait(int batchSize)
batchSize
- the size of the batchvoid pullExpiresIn(int batchSize, java.time.Duration expiresIn)
sub.nextMessage(timeout)
can return a:
Multiple 408 status messages may come. Each one indicates a missing item from the previous batch and can be discarded.
batchSize
- the size of the batchexpiresIn
- how long from now this request should be expired from the server wait listjava.util.List<Message> fetch(int batchSize, java.time.Duration maxWait)
pullExpiresIn
under the covers, and manages all responses
from sub.nextMessage(...)
to only return regular JetStream messages.
This can only be used when the subscription is pull based.batchSize
- the size of the batchmaxWait
- the maximum time to wait for the first message.java.util.Iterator<Message> iterate(int batchSize, java.time.Duration maxWait)
pullExpiresIn
under the covers,
and manages all responses. The iterator will have no messages if it does not
receive the first message within the max wait period. It will stop if the batch is
fulfilled or if there are fewer than batch size messages. 408 Status messages
are ignored and will not count toward the fulfilled batch size.batchSize
- the size of the batchmaxWait
- the maximum time to wait for the first message.ConsumerInfo getConsumerInfo() throws java.io.IOException, JetStreamApiException
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