public interface MessageIterator extends Iterator<Message>, AutoCloseable
Iterator for fetching Nats subscription messages in a blocking manner.| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this subscription iterator.
|
boolean |
hasNext()
Returns
true if this iterator is open. |
Message |
next()
Returns the next
Message sent by the Nats server. |
Message |
next(long timeout,
TimeUnit unit)
Returns the next
Message sent by the Nats server within the specified time limit. |
void |
remove()
Throws an
UnsupportedOperationException since you obviously can't remove a message after it has been
received. |
forEachRemainingboolean hasNext()
true if this iterator is open. We do not know if/when the Nats server will publish another
message so we assume another message is pending so, this method always returns true unless this iterator has
been closed.
Closing the subscription associated with this iterator will close this iterator.
Message next() throws NatsClosedException
Message sent by the Nats server.next in interface Iterator<Message>Message sent by the Nats server.NatsClosedException - thrown if the iterator closes while waiting for a message.Message next(long timeout, TimeUnit unit) throws NatsClosedException
Message sent by the Nats server within the specified time limit.timeout - the maximum time to wait for a messageunit - the time unit of the timeout argumentMessage sent by the Nats server or null if a message didn't arrive within the
specified time limit.NatsClosedException - thrown if the iterator closes while waiting for a message.void remove()
UnsupportedOperationException since you obviously can't remove a message after it has been
received.void close()
Closing the subscription associated with this iterator will close this iterator.
close in interface AutoCloseableCopyright © 2015. All Rights Reserved.