Name
TopicSubscriber
Synopsis
A TopicSubscriber
is a MessageConsumer
specific to a publish/subscribe
context. TopicSubscribers
are created using the createSubscriber()
and
createDurableSubscriber()
methods on the
TopicSession
. TopicSubscribers
are created with a Topic
to subscribe
to, and can optionally be created with a message selector, which
filters the messages received by the subscriber. If a client is both
publishing and subscribing to the same Topic
, then the no-local
attribute on the TopicSubscriber
specifiescan be used to filter out
messages published by the same connection.
If a TopicSubscriber
is created as durable (using the
createDurableSubscriber()
on the TopicSession
), then the provider
collects messages for this subscriber even when the subscriber is
inactive. The provider will keep these messages until the subscriber
receives them, or until they expire according to the sender’s
time-to-live header attribute. In order for the client to retrieve the
messages collected under a durable TopicSubscriber
after it has
reactivated itself, it has to create a new TopicSubscriber
under the
same Topic
with the same client ID.
public interface TopicSubscriber extends MessageConsumer { // Public Instance Methods public abstract boolean getNoLocal() throws JMSException; public abstract Topic getTopic() throws JMSException; }
Returned By
TopicSession.{createDurableSubscriber()
,
Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.