public interface Subscription extends AutoCloseable
Subscription object to receive messages that have been published to a
subject. Each Subscription object is unique, even if the subscription is to the same
subject. This means that if Connection.subscribe("foo", cb) is called twice in a row,
each of the resulting Subscription objects will be unique, and any message delivered on
subject "foo" will be delivered individually to both Subscription objects.
| Modifier and Type | Method and Description |
|---|---|
void |
autoUnsubscribe(int max)
Issues an automatic unsubscribe request.
|
void |
close() |
int |
getDropped()
Returns the number of messages that this subscription has dropped due to "slow consumer"
condition.
|
long |
getMaxPendingBytes()
Returns the maximum number of pending bytes for this subscription.
|
int |
getMaxPendingMsgs()
Returns the maximum number of pending messages for this subscription.
|
String |
getQueue()
Returns the optional queue group name.
|
int |
getQueuedMessageCount()
Returns the number of messages delivered to, but not processed, by this Subscription.
|
String |
getSubject()
Retrieves the subject of interest from the
Subscription object. |
boolean |
isValid()
Returns whether the Subscription object is still active (subscribed).
|
void |
setMaxPendingBytes(long pending)
Sets the maximum number of unprocessed message bytes that can be left pending on this
subscription before a slow consumer exception is thrown.
|
void |
setMaxPendingMsgs(int pending)
Sets the maximum number of unprocessed messages that can be left pending on this subscription
before a slow consumer exception is thrown.
|
void |
setPendingLimits(int msgs,
int bytes)
Sets the the maximum number of unprocessed messages and bytes that can be left pending on
this subscription before messages are dropped and a slow consumer exception is thrown.
|
void |
unsubscribe()
Removes interest in the
Subscription object's subject immediately. |
String getSubject()
Subscription object.String getQueue()
boolean isValid()
void unsubscribe()
throws IOException
Subscription object's subject immediately.IOException - if an error occurs while notifying the servervoid autoUnsubscribe(int max)
throws IOException
max - The number of messages to receive before unsubscribing.IOException - if an error occurs while sending the unsubscribe request to the NATS
server.int getQueuedMessageCount()
int getMaxPendingMsgs()
long getMaxPendingBytes()
void setMaxPendingMsgs(int pending)
pending - the maximum number of pending messagesvoid setMaxPendingBytes(long pending)
pending - the maximum number of pending bytesvoid setPendingLimits(int msgs,
int bytes)
msgs - the maximum number of pending messagesbytes - the maximum number of pending bytesint getDropped()
void close()
close in interface AutoCloseableCopyright © 2015–2016 Apcera, Inc.. All rights reserved.