public interface Subscription extends AutoCloseable, Iterable<Message>
| Modifier and Type | Method and Description |
|---|---|
Registration |
addMessageHandler(MessageHandler messageHandler)
Registers a
MessageHandler instance with this subscription that will be invoked every time the
subscription receives a message. |
void |
close()
Closes this subscription.
|
Integer |
getMaxMessages()
Returns the maximum number of messages this subscription will receive before being closed automatically.
|
String |
getQueueGroup()
Returns the queue group the subscription is participating in.
|
int |
getReceivedMessages()
Returns the number of messages this subscription has received.
|
String |
getSubject()
Returns this subscription's NATS subject.
|
MessageIterator |
iterator()
Creates a
MessageIterator that can be used for fetching messages from this subscription in a
blocking manner. |
forEach, spliteratorvoid close()
MessageHandler objects associated with this request will no longer receive
messages for this subscription after this method is invoked. All MessageIterator objects created by
this subscription will also be closed.close in interface AutoCloseableString getSubject()
int getReceivedMessages()
Integer getMaxMessages()
null if no maximum was specified.String getQueueGroup()
MessageIterator iterator()
MessageIterator that can be used for fetching messages from this subscription in a
blocking manner. Because Subscription implements the Iterable interface, a subscription can be
used in a Java for loop. For example:
for (Message message : nats.subscribe("foo.>") {
System.out.println(message);
}
The for loop may terminate with an exception when the subscription is closed.iterator in interface Iterable<Message>MessageIteratorRegistration addMessageHandler(MessageHandler messageHandler)
MessageHandler instance with this subscription that will be invoked every time the
subscription receives a message.messageHandler - the message handler that is invoked when a message arrivesCopyright © 2015. All Rights Reserved.