public interface JetStream
Modifier and Type | Method and Description |
---|---|
ConsumerContext |
getConsumerContext(java.lang.String streamName,
java.lang.String consumerName)
Get a consumer context for a specific named stream and specific named consumer.
|
StreamContext |
getStreamContext(java.lang.String streamName)
Get a stream context for a specific named stream.
|
PublishAck |
publish(Message message)
Send a message to the specified subject and waits for a response from
Jetstream.
|
PublishAck |
publish(Message message,
PublishOptions options)
Send a message to the specified subject and waits for a response from
Jetstream.
|
PublishAck |
publish(java.lang.String subject,
byte[] body)
Send a message to the specified subject and waits for a response from
Jetstream.
|
PublishAck |
publish(java.lang.String subject,
byte[] body,
PublishOptions options)
Send a message to the specified subject and waits for a response from
Jetstream.
|
PublishAck |
publish(java.lang.String subject,
io.nats.client.impl.Headers headers,
byte[] body)
Send a message to the specified subject and waits for a response from
Jetstream.
|
PublishAck |
publish(java.lang.String subject,
io.nats.client.impl.Headers headers,
byte[] body,
PublishOptions options)
Send a message to the specified subject and waits for a response from
Jetstream.
|
java.util.concurrent.CompletableFuture<PublishAck> |
publishAsync(Message message)
Send a message to the specified subject but does not wait for a response from
Jetstream.
|
java.util.concurrent.CompletableFuture<PublishAck> |
publishAsync(Message message,
PublishOptions options)
Send a message to the specified subject but does not wait for a response from
Jetstream.
|
java.util.concurrent.CompletableFuture<PublishAck> |
publishAsync(java.lang.String subject,
byte[] body)
Send a message to the specified subject but does not wait for a response from
Jetstream.
|
java.util.concurrent.CompletableFuture<PublishAck> |
publishAsync(java.lang.String subject,
byte[] body,
PublishOptions options)
Send a message to the specified subject but does not wait for a response from
Jetstream.
|
java.util.concurrent.CompletableFuture<PublishAck> |
publishAsync(java.lang.String subject,
io.nats.client.impl.Headers headers,
byte[] body)
Send a message to the specified subject but does not wait for a response from
Jetstream.
|
java.util.concurrent.CompletableFuture<PublishAck> |
publishAsync(java.lang.String subject,
io.nats.client.impl.Headers headers,
byte[] body,
PublishOptions options)
Send a message to the specified subject but does not wait for a response from
Jetstream.
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject)
Create a synchronous subscription to the specified subject with default options.
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject,
Dispatcher dispatcher,
MessageHandler handler,
boolean autoAck)
Create an asynchronous subscription to the specified subject under the control of the
specified dispatcher.
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject,
Dispatcher dispatcher,
MessageHandler handler,
boolean autoAck,
PushSubscribeOptions options)
Create an asynchronous subscription to the specified subject under the control of the
specified dispatcher.
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject,
Dispatcher dispatcher,
MessageHandler handler,
PullSubscribeOptions options)
Create an asynchronous subscription to the specified subject in the mode of pull, with additional options
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject,
PullSubscribeOptions options)
Create a subscription to the specified subject in the mode of pull, with additional options
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject,
PushSubscribeOptions options)
Create a synchronous subscription to the specified subject.
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject,
java.lang.String queue,
Dispatcher dispatcher,
MessageHandler handler,
boolean autoAck,
PushSubscribeOptions options)
Create an asynchronous subscription to the specified subject under the control of the
specified dispatcher.
|
JetStreamSubscription |
subscribe(java.lang.String subscribeSubject,
java.lang.String queue,
PushSubscribeOptions options)
Create a synchronous subscription to the specified subject.
|
PublishAck publish(java.lang.String subject, byte[] body) throws java.io.IOException, JetStreamApiException
nc = Nats.connect() JetStream js = nc.JetStream() js.publish("destination", "message".getBytes("UTF-8"))where the sender creates a byte array immediately before calling publish.
subject
- the subject to send the message tobody
- the message bodyjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataPublishAck publish(java.lang.String subject, io.nats.client.impl.Headers headers, byte[] body) throws java.io.IOException, JetStreamApiException
nc = Nats.connect() JetStream js = nc.JetStream() Headers h = new Headers().put("foo", "bar"); js.publish("destination", h, "message".getBytes("UTF-8"))where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.subject
- the subject to send the message toheaders
- Optional headers to publish with the message.body
- the message bodyjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataPublishAck publish(java.lang.String subject, byte[] body, PublishOptions options) throws java.io.IOException, JetStreamApiException
nc = Nats.connect() JetStream js = nc.JetStream() js.publish("destination", "message".getBytes("UTF-8"), publishOptions)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.subject
- the subject to send the message tobody
- the message bodyoptions
- publisher optionsjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataPublishAck publish(java.lang.String subject, io.nats.client.impl.Headers headers, byte[] body, PublishOptions options) throws java.io.IOException, JetStreamApiException
nc = Nats.connect() JetStream js = nc.JetStream() Headers h = new Headers().put("foo", "bar"); js.publish("destination", h, "message".getBytes("UTF-8"), publishOptions)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.subject
- the subject to send the message toheaders
- Optional headers to publish with the message.body
- the message bodyoptions
- publisher optionsjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataPublishAck publish(Message message) throws java.io.IOException, JetStreamApiException
nc = Nats.connect() JetStream js = nc.JetStream() js.publish(message)where the sender creates a byte array immediately before calling publish.
The Message object allows you to set a replyTo, but in publish requests, the replyTo is reserved for internal use as the address for the server to respond to the client with the PublishAck.
Seepublish()
for more details on
publish during reconnect.message
- the message to sendjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataPublishAck publish(Message message, PublishOptions options) throws java.io.IOException, JetStreamApiException
nc = Nats.connect() JetStream js = nc.JetStream() js.publish(message, publishOptions)where the sender creates a byte array immediately before calling publish.
The Message object allows you to set a replyTo, but in publish requests, the replyTo is reserved for internal use as the address for the server to respond to the client with the PublishAck.
Seepublish()
for more details on
publish during reconnect.message
- the message to sendoptions
- publisher optionsjava.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.concurrent.CompletableFuture<PublishAck> publishAsync(java.lang.String subject, byte[] body)
nc = Nats.connect() JetStream js = nc.JetStream() CompletableFuture<PublishAck> future = js.publishAsync("destination", "message".getBytes("UTF-8"),)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.
The future me be completed with an exception, either
an IOException covers various communication issues with the NATS server such as timeout or interruption
- or - a JetStreamApiException the request had an error related to the datasubject
- the subject to send the message tobody
- the message bodyjava.util.concurrent.CompletableFuture<PublishAck> publishAsync(java.lang.String subject, io.nats.client.impl.Headers headers, byte[] body)
nc = Nats.connect() JetStream js = nc.JetStream() Headers h = new Headers().put("foo", "bar"); CompletableFuture<PublishAck> future = js.publishAsync("destination", h, "message".getBytes("UTF-8"),)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.
The future me be completed with an exception, either
an IOException covers various communication issues with the NATS server such as timeout or interruption
- or - a JetStreamApiException the request had an error related to the datasubject
- the subject to send the message toheaders
- Optional headers to publish with the message.body
- the message bodyjava.util.concurrent.CompletableFuture<PublishAck> publishAsync(java.lang.String subject, byte[] body, PublishOptions options)
nc = Nats.connect() JetStream js = nc.JetStream() CompletableFuture<PublishAck> future = js.publishAsync("destination", "message".getBytes("UTF-8"), publishOptions)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.
The future me be completed with an exception, either
an IOException covers various communication issues with the NATS server such as timeout or interruption
- or - a JetStreamApiException the request had an error related to the datasubject
- the subject to send the message tobody
- the message bodyoptions
- publisher optionsjava.util.concurrent.CompletableFuture<PublishAck> publishAsync(java.lang.String subject, io.nats.client.impl.Headers headers, byte[] body, PublishOptions options)
nc = Nats.connect() JetStream js = nc.JetStream() Headers h = new Headers().put("foo", "bar"); CompletableFuture<PublishAck> future = js.publishAsync("destination", h, "message".getBytes("UTF-8"), publishOptions)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.
The future me be completed with an exception, either
an IOException covers various communication issues with the NATS server such as timeout or interruption
- or - a JetStreamApiException the request had an error related to the datasubject
- the subject to send the message toheaders
- Optional headers to publish with the message.body
- the message bodyoptions
- publisher optionsjava.util.concurrent.CompletableFuture<PublishAck> publishAsync(Message message)
nc = Nats.connect() JetStream js = nc.JetStream() CompletableFuture<PublishAck> future = js.publishAsync(message)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.
The future me be completed with an exception, either
an IOException covers various communication issues with the NATS server such as timeout or interruption
- or - a JetStreamApiException the request had an error related to the data
The Message object allows you to set a replyTo, but in publish requests, the replyTo is reserved for internal use as the address for the server to respond to the client with the PublishAck.
message
- the message to sendjava.util.concurrent.CompletableFuture<PublishAck> publishAsync(Message message, PublishOptions options)
nc = Nats.connect() JetStream js = nc.JetStream() CompletableFuture<PublishAck> future = js.publishAsync(message, publishOptions)where the sender creates a byte array immediately before calling publish. See
publish()
for more details on
publish during reconnect.
The future me be completed with an exception, either
an IOException covers various communication issues with the NATS server such as timeout or interruption
- or - a JetStreamApiException the request had an error related to the data
The Message object allows you to set a replyTo, but in publish requests, the replyTo is reserved for internal use as the address for the server to respond to the client with the PublishAck.
message
- the message to publishoptions
- publisher optionsJetStreamSubscription subscribe(java.lang.String subscribeSubject) throws java.io.IOException, JetStreamApiException
Use the Subscription.nextMessage(Duration)
method to read messages for this subscription.
See createDispatcher
for
information about creating an asynchronous subscription with callbacks.
subscribeSubject
- the subject to subscribe tojava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataJetStreamSubscription subscribe(java.lang.String subscribeSubject, PushSubscribeOptions options) throws java.io.IOException, JetStreamApiException
Use the Subscription.nextMessage(Duration)
method to read messages for this subscription.
See createDispatcher
for
information about creating an asynchronous subscription with callbacks.
subscribeSubject
- the subject to subscribe to.
Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject.options
- optional subscription optionsjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataJetStreamSubscription subscribe(java.lang.String subscribeSubject, java.lang.String queue, PushSubscribeOptions options) throws java.io.IOException, JetStreamApiException
Use the nextMessage
method to read messages for this subscription.
See createDispatcher
for
information about creating an asynchronous subscription with callbacks.
subscribeSubject
- the subject to subscribe to
Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject.queue
- the optional queue group to joinoptions
- optional subscription optionsjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataJetStreamSubscription subscribe(java.lang.String subscribeSubject, Dispatcher dispatcher, MessageHandler handler, boolean autoAck) throws java.io.IOException, JetStreamApiException
subscribeSubject
- The subject to subscribe todispatcher
- The dispatcher to handle this subscriptionhandler
- The target for the messagesautoAck
- Whether to auto ackjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataJetStreamSubscription subscribe(java.lang.String subscribeSubject, Dispatcher dispatcher, MessageHandler handler, boolean autoAck, PushSubscribeOptions options) throws java.io.IOException, JetStreamApiException
subscribeSubject
- The subject to subscribe to.
Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject.dispatcher
- The dispatcher to handle this subscriptionhandler
- The target for the messagesautoAck
- Whether to auto ackoptions
- The options for this subscription.java.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataJetStreamSubscription subscribe(java.lang.String subscribeSubject, java.lang.String queue, Dispatcher dispatcher, MessageHandler handler, boolean autoAck, PushSubscribeOptions options) throws java.io.IOException, JetStreamApiException
subscribeSubject
- The subject to subscribe to.
Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject.queue
- the optional queue group to joindispatcher
- The dispatcher to handle this subscriptionhandler
- The target for the messagesautoAck
- Whether to auto ackoptions
- optional subscription optionsjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataJetStreamSubscription subscribe(java.lang.String subscribeSubject, PullSubscribeOptions options) throws java.io.IOException, JetStreamApiException
subscribeSubject
- The subject to subscribe to
Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject.options
- pull subscription optionsjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataJetStreamSubscription subscribe(java.lang.String subscribeSubject, Dispatcher dispatcher, MessageHandler handler, PullSubscribeOptions options) throws java.io.IOException, JetStreamApiException
subscribeSubject
- The subject to subscribe to
Can be null or empty when the options have a ConsumerConfiguration that supplies a filter subject.dispatcher
- The dispatcher to handle this subscriptionhandler
- The target for the messagesoptions
- pull subscription optionsjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataStreamContext getStreamContext(java.lang.String streamName) throws java.io.IOException, JetStreamApiException
streamName
- the name of the streamjava.io.IOException
- covers various communication issues with the NATS
server such as timeout or interruptionJetStreamApiException
- the request had an error related to the dataConsumerContext getConsumerContext(java.lang.String streamName, java.lang.String consumerName) throws java.io.IOException, JetStreamApiException
streamName
- the name of the streamconsumerName
- 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