public interface StreamingConnection extends AutoCloseable
StreamingConnection object is a client's active connection to the STAN streaming
data system.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection.
|
io.nats.client.Connection |
getNatsConnection()
Returns the underlying NATS connection.
|
void |
publish(String subject,
byte[] data)
Publishes the payload specified by
data to the subject specified by subject,
and blocks until an ACK or error is returned. |
String |
publish(String subject,
byte[] data,
AckHandler ah)
Publishes the payload specified by
data to the subject specified by subject
and asynchronously processes the ACK or error state via the supplied AckHandler |
Subscription |
subscribe(String subject,
MessageHandler cb)
Creates a
Subscription with interest in a given subject, assigns the callback, and
immediately starts receiving messages. |
Subscription |
subscribe(String subject,
MessageHandler cb,
SubscriptionOptions opts)
Creates a
Subscription with interest in a given subject using the given
SubscriptionOptions, assigns the callback, and immediately starts receiving messages. |
Subscription |
subscribe(String subject,
String queue,
MessageHandler cb)
Creates a
Subscription in the queue group specified by queue with interest in
a given subject, assigns the message callback, and immediately starts receiving messages. |
Subscription |
subscribe(String subject,
String queue,
MessageHandler cb,
SubscriptionOptions opts)
Creates a
Subscription in the queue group specified by queue with interest in
a given subject, assigns the message callback, and immediately starts receiving messages. |
void publish(String subject, byte[] data) throws IOException, InterruptedException
data to the subject specified by subject,
and blocks until an ACK or error is returned.subject - the subject to which the message is to be publisheddata - the message payloadIOException - if the publish operation is not successfulInterruptedException - if the calling thread is interrupted before the call completesIllegalStateException - if the connection is closedString publish(String subject, byte[] data, AckHandler ah) throws IOException, InterruptedException
data to the subject specified by subject
and asynchronously processes the ACK or error state via the supplied AckHandlersubject - the subject to which the message is to be publisheddata - the message payloadah - the AckHandler to invoke when an ack is received, passing the
message GUID
and any error information.IOException - if an I/O exception is encounteredInterruptedException - if the calling thread is interrupted before the call completesIllegalStateException - if the connection is closedAckHandlerSubscription subscribe(String subject, MessageHandler cb) throws IOException, InterruptedException
Subscription with interest in a given subject, assigns the callback, and
immediately starts receiving messages.subject - the subject of interestcb - a MessageHandler callback used to process messages received by the
SubscriptionSubscription object, or null if the subscription request timed outIOException - if an I/O exception is encounteredInterruptedException - if the calling thread is interrupted before the call completesMessageHandler,
SubscriptionSubscription subscribe(String subject, MessageHandler cb, SubscriptionOptions opts) throws IOException, InterruptedException
Subscription with interest in a given subject using the given
SubscriptionOptions, assigns the callback, and immediately starts receiving messages.subject - the subject of interestcb - a MessageHandler callback used to process messages received by the
Subscriptionopts - the SubscriptionOptions to configure this SubscriptionSubscription object, or null if the subscription request timed outIOException - if an I/O exception is encounteredInterruptedException - if the calling thread is interrupted before the call completesMessageHandler,
Subscription,
SubscriptionOptionsSubscription subscribe(String subject, String queue, MessageHandler cb) throws IOException, InterruptedException
Subscription in the queue group specified by queue with interest in
a given subject, assigns the message callback, and immediately starts receiving messages.subject - the subject of interestqueue - optional queue groupcb - a MessageHandler callback used to process messages received by the
SubscriptionSubscription object, or null if the subscription request timed outIOException - if an I/O exception is encounteredInterruptedException - if the calling thread is interrupted before the call completesSubscription subscribe(String subject, String queue, MessageHandler cb, SubscriptionOptions opts) throws IOException, InterruptedException
Subscription in the queue group specified by queue with interest in
a given subject, assigns the message callback, and immediately starts receiving messages.subject - the subject of interestqueue - optional queue groupcb - a MessageHandler callback used to process messages received by the
Subscriptionopts - the SubscriptionOptions to configure for this SubscriptionSubscription object, or null if the subscription request timed outIOException - if an I/O exception is encounteredInterruptedException - if the calling thread is interrupted before the call completesio.nats.client.Connection getNatsConnection()
Connectionvoid close()
throws IOException,
TimeoutException,
InterruptedException
close in interface AutoCloseableIOException - if an error occursTimeoutException - if the close request is not responded to within the timeout period.InterruptedExceptionCopyright © 2016–2018 NATS.io. All rights reserved.