public interface JetStreamManagement
Using JetStream Management is the recommended way of managing Jetstream resources.
Basic usage examples can be found in JetStream
| Modifier and Type | Method and Description |
|---|---|
ConsumerInfo |
addOrUpdateConsumer(java.lang.String streamName,
ConsumerConfiguration config)
Loads or creates a consumer.
|
StreamInfo |
addStream(StreamConfiguration config)
Loads or creates a stream.
|
ConsumerInfo |
createConsumer(java.lang.String streamName,
ConsumerConfiguration config)
Creates a consumer.
|
boolean |
deleteConsumer(java.lang.String streamName,
java.lang.String consumerName)
Deletes a consumer.
|
boolean |
deleteMessage(java.lang.String streamName,
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(java.lang.String streamName,
long seq,
boolean erase)
Deletes a message, optionally erasing the content of the message.
|
boolean |
deleteStream(java.lang.String streamName)
Deletes an existing stream.
|
AccountStatistics |
getAccountStatistics()
Gets the account statistics for the logged in account.
|
ConsumerInfo |
getConsumerInfo(java.lang.String streamName,
java.lang.String consumerName)
Gets the info for an existing consumer.
|
java.util.List<java.lang.String> |
getConsumerNames(java.lang.String streamName)
Return a list of consumers by name
|
java.util.List<ConsumerInfo> |
getConsumers(java.lang.String streamName)
Return a list of ConsumerInfo objects.
|
MessageInfo |
getFirstMessage(java.lang.String streamName,
java.lang.String subject)
Get MessageInfo for the first message of the subject.
|
MessageInfo |
getFirstMessage(java.lang.String streamName,
java.time.ZonedDateTime startTime)
Get MessageInfo for the first message created at or after the start time.
|
MessageInfo |
getFirstMessage(java.lang.String streamName,
java.time.ZonedDateTime startTime,
java.lang.String subject)
Get MessageInfo for the first message created at or after the start time matching the subject.
|
MessageInfo |
getLastMessage(java.lang.String streamName,
java.lang.String subject)
Get MessageInfo for the last message of the subject.
|
MessageInfo |
getMessage(java.lang.String streamName,
long seq)
Get MessageInfo for the message with the exact sequence in the stream.
|
MessageInfo |
getMessage(java.lang.String streamName,
io.nats.client.api.MessageGetRequest messageGetRequest)
Get MessageInfo for the message matching the
MessageGetRequest. |
MessageInfo |
getNextMessage(java.lang.String streamName,
long seq,
java.lang.String subject)
Get MessageInfo for the message of the message sequence
is equal to or greater the requested sequence for the subject.
|
StreamInfo |
getStreamInfo(java.lang.String streamName)
Gets the info for an existing stream.
|
StreamInfo |
getStreamInfo(java.lang.String streamName,
StreamInfoOptions options)
Gets the info for an existing stream, and include subject or deleted details
as defined by StreamInfoOptions.
|
java.util.List<java.lang.String> |
getStreamNames()
Get the names of all streams.
|
java.util.List<java.lang.String> |
getStreamNames(java.lang.String subjectFilter)
Get a list of stream names that have subjects matching the subject filter.
|
java.util.List<StreamInfo> |
getStreams()
Return a list of StreamInfo objects.
|
java.util.List<StreamInfo> |
getStreams(java.lang.String subjectFilter)
Return a list of StreamInfo objects that have subjects matching the filter.
|
JetStream |
jetStream()
Gets a context for publishing and subscribing to subjects backed by Jetstream streams
and consumers, using the same connection and JetStreamOptions as the management.
|
ConsumerPauseResponse |
pauseConsumer(java.lang.String streamName,
java.lang.String consumerName,
java.time.ZonedDateTime pauseUntil)
Pauses a consumer.
|
PurgeResponse |
purgeStream(java.lang.String streamName)
Purge stream messages
|
PurgeResponse |
purgeStream(java.lang.String streamName,
PurgeOptions options)
Purge messages for a specific subject
|
boolean |
resumeConsumer(java.lang.String streamName,
java.lang.String consumerName)
Resumes a paused consumer.
|
ConsumerInfo |
updateConsumer(java.lang.String streamName,
ConsumerConfiguration config)
Updates an existing consumer.
|
StreamInfo |
updateStream(StreamConfiguration config)
Updates an existing stream.
|
AccountStatistics getAccountStatistics() 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 datajava.lang.IllegalArgumentException - the server is not JetStream enabledStreamInfo addStream(StreamConfiguration config) throws java.io.IOException, JetStreamApiException
config - the stream 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 datajava.lang.IllegalArgumentException - the configuration is missing or invalidStreamInfo updateStream(StreamConfiguration config) throws java.io.IOException, JetStreamApiException
config - the stream 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 datajava.lang.IllegalArgumentException - the configuration is missing or invalidboolean deleteStream(java.lang.String streamName)
throws java.io.IOException,
JetStreamApiException
streamName - the stream name 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 dataStreamInfo getStreamInfo(java.lang.String streamName) throws java.io.IOException, JetStreamApiException
streamName - the stream name 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 dataStreamInfo getStreamInfo(java.lang.String streamName, StreamInfoOptions options) throws java.io.IOException, JetStreamApiException
streamName - the stream name to use.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 dataPurgeResponse purgeStream(java.lang.String streamName) throws java.io.IOException, JetStreamApiException
streamName - the stream name 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 dataPurgeResponse purgeStream(java.lang.String streamName, PurgeOptions options) throws java.io.IOException, JetStreamApiException
streamName - the stream name to use.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 dataConsumerInfo addOrUpdateConsumer(java.lang.String streamName, ConsumerConfiguration config) throws java.io.IOException, JetStreamApiException
streamName - name of the streamconfig - 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 dataConsumerInfo createConsumer(java.lang.String streamName, ConsumerConfiguration config) throws java.io.IOException, JetStreamApiException
streamName - name of the streamconfig - 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 such as the consumer already existsConsumerInfo updateConsumer(java.lang.String streamName, ConsumerConfiguration config) throws java.io.IOException, JetStreamApiException
streamName - name of the streamconfig - 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 such as the consumer does not already existboolean deleteConsumer(java.lang.String streamName,
java.lang.String consumerName)
throws java.io.IOException,
JetStreamApiException
streamName - name of the streamconsumerName - 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.ConsumerPauseResponse pauseConsumer(java.lang.String streamName, java.lang.String consumerName, java.time.ZonedDateTime pauseUntil) throws java.io.IOException, JetStreamApiException
streamName - name of the streamconsumerName - the name of the consumer.pauseUntil - consumer is paused until this time.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.boolean resumeConsumer(java.lang.String streamName,
java.lang.String consumerName)
throws java.io.IOException,
JetStreamApiException
streamName - name of the streamconsumerName - 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.ConsumerInfo getConsumerInfo(java.lang.String streamName, java.lang.String consumerName) throws java.io.IOException, JetStreamApiException
streamName - name of the streamconsumerName - 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 datajava.util.List<java.lang.String> getConsumerNames(java.lang.String streamName)
throws java.io.IOException,
JetStreamApiException
streamName - the name of the stream.java.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the datajava.util.List<ConsumerInfo> getConsumers(java.lang.String streamName) throws java.io.IOException, JetStreamApiException
streamName - the name of the stream.java.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the datajava.util.List<java.lang.String> getStreamNames()
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 datajava.util.List<java.lang.String> getStreamNames(java.lang.String subjectFilter)
throws java.io.IOException,
JetStreamApiException
subjectFilter - the subject. Wildcards are allowed.java.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the datajava.util.List<StreamInfo> getStreams() 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 datajava.util.List<StreamInfo> getStreams(java.lang.String subjectFilter) throws java.io.IOException, JetStreamApiException
subjectFilter - the filter to limit the streams by subjects. Wildcards allowed.java.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the dataMessageInfo getMessage(java.lang.String streamName, long seq) throws java.io.IOException, JetStreamApiException
streamName - the name of the stream.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 dataMessageInfo getMessage(java.lang.String streamName, io.nats.client.api.MessageGetRequest messageGetRequest) throws java.io.IOException, JetStreamApiException
MessageGetRequest.streamName - the name of the stream.messageGetRequest - the MessageGetRequest to get a messagejava.io.IOException - covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException - the request had an error related to the dataMessageInfo getLastMessage(java.lang.String streamName, java.lang.String subject) throws java.io.IOException, JetStreamApiException
streamName - the name of the stream.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 dataMessageInfo getFirstMessage(java.lang.String streamName, java.lang.String subject) throws java.io.IOException, JetStreamApiException
streamName - the name of the stream.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 dataMessageInfo getFirstMessage(java.lang.String streamName, java.time.ZonedDateTime startTime) throws java.io.IOException, JetStreamApiException
This API 1) is currently EXPERIMENTAL and is subject to change. 2) Works on Server 2.11 or later
streamName - the name of the stream.startTime - the start time 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 dataMessageInfo getFirstMessage(java.lang.String streamName, java.time.ZonedDateTime startTime, java.lang.String subject) throws java.io.IOException, JetStreamApiException
This API 1) is currently EXPERIMENTAL and is subject to change. 2) Works on Server 2.11 or later
streamName - the name of the stream.startTime - the start time to get the first message for.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 dataMessageInfo getNextMessage(java.lang.String streamName, long seq, java.lang.String subject) throws java.io.IOException, JetStreamApiException
streamName - the name of the stream.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(java.lang.String streamName,
long seq)
throws java.io.IOException,
JetStreamApiException
streamName - name of the streamseq - 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(java.lang.String streamName,
long seq,
boolean erase)
throws java.io.IOException,
JetStreamApiException
streamName - name of the streamseq - 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 dataJetStream jetStream()