public interface StreamContext
For basic usage examples see JetStream
| Modifier and Type | Method and Description |
|---|---|
@NonNull OrderedConsumerContext |
createOrderedConsumer(@NonNull OrderedConsumerConfiguration config)
Create an ordered consumer context for the context's stream.
|
@NonNull ConsumerContext |
createOrUpdateConsumer(@NonNull ConsumerConfiguration config)
Management function to create or update a consumer on this stream.
|
boolean |
deleteConsumer(@NonNull java.lang.String consumerName)
Management function to deletes a consumer.
|
boolean |
deleteMessage(long seq)
Deletes a message, overwriting the message data with garbage
This can be considered an expensive (time-consuming) operation, but is more secure.
|
boolean |
deleteMessage(long seq,
boolean erase)
Deletes a message, optionally erasing the content of the message.
|
@NonNull ConsumerContext |
getConsumerContext(@NonNull java.lang.String consumerName)
Get a consumer context for the context's stream and specific named consumer.
|
@NonNull ConsumerInfo |
getConsumerInfo(@NonNull java.lang.String consumerName)
Gets the info for an existing consumer.
|
@NonNull java.util.List<java.lang.String> |
getConsumerNames()
Return a list of consumers by name
|
@NonNull java.util.List<ConsumerInfo> |
getConsumers()
Return a list of ConsumerInfo objects.
|
@NonNull MessageInfo |
getFirstMessage(@NonNull java.lang.String subject)
Get MessageInfo for the first message of the subject.
|
@NonNull MessageInfo |
getLastMessage(@NonNull java.lang.String subject)
Get MessageInfo for the last message of the subject.
|
@NonNull MessageInfo |
getMessage(long seq)
Get MessageInfo for the message with the exact sequence in the stream.
|
@NonNull MessageInfo |
getNextMessage(long seq,
@NonNull java.lang.String subject)
Get MessageInfo for the message of the message sequence
is equal to or greater the requested sequence for the subject.
|
@NonNull StreamInfo |
getStreamInfo()
Gets information about the stream for this context.
|
@NonNull StreamInfo |
getStreamInfo(@Nullable StreamInfoOptions options)
Gets information about the stream for this context.
|
@NonNull java.lang.String |
getStreamName()
Gets the stream name that was used to create the context.
|
@NonNull PurgeResponse |
purge()
Purge stream messages
|
@NonNull PurgeResponse |
purge(PurgeOptions options)
Purge messages for a specific subject
|
@NonNull java.lang.String getStreamName()
@NonNull StreamInfo getStreamInfo() 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,
most likely the stream has been removed since the context was created.@NonNull StreamInfo getStreamInfo(@Nullable StreamInfoOptions options) throws java.io.IOException, JetStreamApiException
options - the stream info options. If null, request will not return any optional data.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,
most likely the stream has been removed since the context was created.@NonNull PurgeResponse purge() 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@NonNull PurgeResponse purge(PurgeOptions options) throws java.io.IOException, JetStreamApiException
options - the purge 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 ConsumerContext getConsumerContext(@NonNull java.lang.String consumerName) throws java.io.IOException, JetStreamApiException
Note that ConsumerContext expects a pull consumer.
consumerName - the name of the consumerjava.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 ConsumerContext createOrUpdateConsumer(@NonNull ConsumerConfiguration config) throws java.io.IOException, JetStreamApiException
Note that ConsumerContext expects a pull consumer.
config - the consumer configuration to use.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 OrderedConsumerContext createOrderedConsumer(@NonNull OrderedConsumerConfiguration config) throws java.io.IOException, JetStreamApiException
config - the configuration for the ordered consumerjava.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the databoolean deleteConsumer(@NonNull java.lang.String consumerName)
throws java.io.IOException,
JetStreamApiException
consumerName - the name of the consumer.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, for instance the consumer does not exist.@NonNull ConsumerInfo getConsumerInfo(@NonNull java.lang.String consumerName) throws java.io.IOException, JetStreamApiException
consumerName - the name of the consumer.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 java.util.List<java.lang.String> getConsumerNames()
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@NonNull java.util.List<ConsumerInfo> getConsumers() 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@NonNull MessageInfo getMessage(long seq) throws java.io.IOException, JetStreamApiException
seq - the sequence number of the messagejava.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 MessageInfo getLastMessage(@NonNull java.lang.String subject) throws java.io.IOException, JetStreamApiException
subject - the subject to get the last message for.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 MessageInfo getFirstMessage(@NonNull java.lang.String subject) throws java.io.IOException, JetStreamApiException
subject - the subject to get the first message for.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 MessageInfo getNextMessage(long seq, @NonNull java.lang.String subject) throws java.io.IOException, JetStreamApiException
seq - the first possible sequence number of the messagesubject - the subject to get the next message for.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 deleteMessage(long seq)
throws java.io.IOException,
JetStreamApiException
seq - the sequence number of the messagejava.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the databoolean deleteMessage(long seq,
boolean erase)
throws java.io.IOException,
JetStreamApiException
seq - the sequence number of the messageerase - whether to erase the message (overwriting with garbage) or only mark it as erased.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