public interface JetStreamSubscription extends Subscription
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.
|
java.util.List<Message> |
fetch(int batchSize,
long maxWaitMillis)
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.lang.String |
getConsumerName()
Gets the consumer name that was used to create the subscription.
|
java.util.Iterator<Message> |
iterate(int batchSize,
java.time.Duration maxWait)
Prepares an iterator.
|
java.util.Iterator<Message> |
iterate(int batchSize,
long maxWaitMillis)
Prepares an iterator.
|
void |
pull(int batchSize)
Initiate pull with the specified batch size.
|
void |
pull(PullRequestOptions pullRequestOptions)
Initiate pull with the specified request options
! Pull subscriptions only.
|
void |
pullExpiresIn(int batchSize,
java.time.Duration expiresIn)
Initiate pull for all messages available before expiration.
|
void |
pullExpiresIn(int batchSize,
long expiresInMillis)
Initiate pull for all messages available before expiration.
|
void |
pullNoWait(int batchSize)
Initiate pull in noWait mode with the specified batch size.
|
void |
pullNoWait(int batchSize,
java.time.Duration expiresIn)
Initiate pull in noWait mode with the specified batch size.
|
void |
pullNoWait(int batchSize,
long expiresInMillis)
Initiate pull in noWait mode with the specified batch size.
|
JetStreamReader |
reader(int batchSize,
int repullAt)
Prepares a reader.
|
getDispatcher, getQueueName, getSubject, nextMessage, nextMessage, unsubscribe, unsubscribe
clearDroppedCount, drain, getDeliveredCount, getDroppedCount, getPendingByteCount, getPendingByteLimit, getPendingMessageCount, getPendingMessageLimit, isActive, setPendingLimits
java.lang.String getConsumerName()
void pull(int batchSize)
batchSize
- the size of the batchjava.lang.IllegalStateException
- if not a pull subscription.void pull(PullRequestOptions pullRequestOptions)
pullRequestOptions
- the options objectjava.lang.IllegalStateException
- if not a pull subscription.void pullNoWait(int batchSize)
batchSize
- the size of the batchjava.lang.IllegalStateException
- if not a pull subscription.void pullNoWait(int batchSize, java.time.Duration expiresIn)
batchSize
- the size of the batchexpiresIn
- how long from now this request should be expired from the server wait listjava.lang.IllegalStateException
- if not a pull subscription.void pullNoWait(int batchSize, long expiresInMillis)
batchSize
- the size of the batchexpiresInMillis
- how long from now this request should be expired from the server wait list, in millisecondsjava.lang.IllegalStateException
- if not a pull subscription.void pullExpiresIn(int batchSize, java.time.Duration expiresIn)
sub.nextMessage(timeout)
can return a:
! Pull subscriptions only. Push subscription will throw IllegalStateException ! Primitive API for ADVANCED use only, officially not supported. Prefer fetch, iterate or reader.
batchSize
- the size of the batchexpiresIn
- how long from now this request should be expired from the server wait listjava.lang.IllegalStateException
- if not a pull subscription.void pullExpiresIn(int batchSize, long expiresInMillis)
sub.nextMessage(timeout)
can return a:
! Pull subscriptions only. Push subscription will throw IllegalStateException ! Primitive API for ADVANCED use only, officially not supported. Prefer fetch, iterate or reader.
batchSize
- the size of the batchexpiresInMillis
- how long from now this request should be expired from the server wait list, in millisecondsjava.lang.IllegalStateException
- if not a pull subscription.java.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.
! Pull subscriptions only. Push subscription will throw IllegalStateExceptionbatchSize
- the size of the batchmaxWait
- the maximum time to wait for the first message.java.lang.IllegalStateException
- if not a pull subscription.java.util.List<Message> fetch(int batchSize, long maxWaitMillis)
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.
! Pull subscriptions only. Push subscription will throw IllegalStateExceptionbatchSize
- the size of the batchmaxWaitMillis
- the maximum time to wait for the first message, in milliseconds.java.lang.IllegalStateException
- if not a pull subscription.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.
! Pull subscriptions only. Push subscription will throw IllegalStateExceptionbatchSize
- the size of the batchmaxWait
- the maximum time to wait for the first message.java.lang.IllegalStateException
- if not a pull subscription.java.util.Iterator<Message> iterate(int batchSize, long maxWaitMillis)
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.
! Pull subscriptions only. Push subscription will throw IllegalStateExceptionbatchSize
- the size of the batchmaxWaitMillis
- the maximum time to wait for the first message, in milliseconds.java.lang.IllegalStateException
- if not a pull subscription.JetStreamReader reader(int batchSize, int repullAt)
batchSize
- the size of the batchrepullAt
- the point in the current batch to tell the server to start the next batchjava.lang.IllegalStateException
- if not a pull subscription.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