-
- All Superinterfaces:
- AutoCloseable, MessageConsumer
public interface TopicSubscriber extends MessageConsumer
A client uses aTopicSubscriber
object to receive messages that have been published to a topic. ATopicSubscriber
object is the publish/subscribe form of a message consumer. AMessageConsumer
can be created by usingSession.createConsumer
.A
TopicSession
allows the creation of multipleTopicSubscriber
objects per topic. It will deliver each message for a topic to each subscriber eligible to receive it. Each copy of the message is treated as a completely separate message. Work done on one copy has no effect on the others; acknowledging one does not acknowledge the others; one message may be delivered immediately, while another waits for its subscriber to process messages ahead of it.Regular
TopicSubscriber
objects are not durable. They receive only messages that are published while they are active.Messages filtered out by a subscriber's message selector will never be delivered to the subscriber. From the subscriber's perspective, they do not exist.
In some cases, a connection may both publish and subscribe to a topic. The subscriber
NoLocal
attribute allows a subscriber to inhibit the delivery of messages published by its own connection.If a client needs to receive all the messages published on a topic, including the ones published while the subscriber is inactive, it uses a durable
TopicSubscriber
. The JMS provider retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are acknowledged by this durable subscriber or they have expired.Sessions with durable subscribers must always provide the same client identifier. In addition, each client must specify a name that uniquely identifies (within client identifier) each durable subscription it creates. Only one session at a time can have a
TopicSubscriber
for a particular durable subscription.A client can change an existing durable subscription by creating a durable
TopicSubscriber
with the same name and a new topic and/or message selector. Changing a durable subscription is equivalent to unsubscribing (deleting) the old one and creating a new one.The
unsubscribe
method is used to delete a durable subscription. Theunsubscribe
method can be used at theSession
orTopicSession
level. This method deletes the state being maintained on behalf of the subscriber by its provider.Creating a
MessageConsumer
provides the same features as creating aTopicSubscriber
. To create a durable subscriber, use ofSession.CreateDurableSubscriber
is recommended. TheTopicSubscriber
is provided to support existing code.- Since:
- JMS 1.0
- Version:
- JMS 2.0
- See Also:
Session.createConsumer(javax.jms.Destination)
,Session.createDurableSubscriber(javax.jms.Topic, java.lang.String)
,TopicSession
,TopicSession.createSubscriber(javax.jms.Topic)
,MessageConsumer
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description boolean
getNoLocal()
Gets theNoLocal
attribute for this subscriber.Topic
getTopic()
Gets theTopic
associated with this subscriber.-
Methods inherited from interface javax.jms.MessageConsumer
close, getMessageListener, getMessageSelector, receive, receive, receiveNoWait, setMessageListener
-
-
-
-
Method Detail
-
getTopic
Topic getTopic() throws JMSException
Gets theTopic
associated with this subscriber.- Returns:
- this subscriber's
Topic
- Throws:
JMSException
- if the JMS provider fails to get the topic for this topic subscriber due to some internal error.
-
getNoLocal
boolean getNoLocal() throws JMSException
Gets theNoLocal
attribute for this subscriber. The default value for this attribute is false.- Returns:
- true if locally published messages are being inhibited
- Throws:
JMSException
- if the JMS provider fails to get theNoLocal
attribute for this topic subscriber due to some internal error.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/jms/TopicSubscriber.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.