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 |
clearMaxPending()
Clears the the maximum number of unprocessed messages and bytes for this subscription.
|
void |
close()
.
|
long |
getDelivered()
Returns the number of messages delivered to, but not processed, by this Subscription.
|
int |
getDropped()
Returns the number of messages that this subscription has dropped due to "slow consumer"
condition.
|
int |
getPendingBytes()
Returns the current number of pending bytes for this subscription.
|
int |
getPendingBytesLimit()
Returns the maximum number of unprocessed message bytes that can be left pending on this
subscription before messages are dropped and a slow consumer exception is thrown.
|
long |
getPendingBytesMax()
Returns the maximum number of pending bytes seen for this subscription.
|
int |
getPendingMsgs()
Returns the current number of pending messages for this subscription.
|
int |
getPendingMsgsLimit()
Returns the maximum number of unprocessed messages that can be left pending on this
subscription before messages are dropped and a slow consumer exception is thrown.
|
int |
getPendingMsgsMax()
Returns the maximum number of pending messages seen for this subscription.
|
String |
getQueue()
Returns the optional queue group name.
|
int |
getQueuedMessageCount()
Deprecated.
use getPending instead
|
String |
getSubject()
Retrieves the subject of interest from the
Subscription object. |
boolean |
isValid()
Returns whether the Subscription object is still active (subscribed).
|
void |
setPendingLimits(int msgs,
int bytes)
Sets 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.long getDelivered()
@Deprecated int getQueuedMessageCount()
int getPendingMsgs()
int getPendingBytes()
int getPendingMsgsMax()
long getPendingBytesMax()
void setPendingLimits(int msgs, int bytes)
msgs
- the maximum number of pending messagesbytes
- the maximum number of pending bytesint getPendingMsgsLimit()
int getPendingBytesLimit()
void clearMaxPending()
int getDropped()
void close()
close
in interface AutoCloseable
Copyright © 2015–2016 Apcera, Inc.. All rights reserved.