javax.jms

Interface TopicSubscriber

  • All Superinterfaces:
    AutoCloseable, MessageConsumer

    public interface TopicSubscriber
    extends MessageConsumer
    A client uses a TopicSubscriber object to receive messages that have been published to a topic. A TopicSubscriber object is the publish/subscribe form of a message consumer. A MessageConsumer can be created by using Session.createConsumer.

    A TopicSession allows the creation of multiple TopicSubscriber 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. The unsubscribe method can be used at the Session or TopicSession 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 a TopicSubscriber. To create a durable subscriber, use of Session.CreateDurableSubscriber is recommended. The TopicSubscriber 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 Detail

      • getTopic

        Topic getTopic()
                throws JMSException
        Gets the Topic 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 the NoLocal 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 the NoLocal attribute for this topic subscriber due to some internal error.

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/jms/TopicSubscriber.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com, TopicSubscriber (Java(TM) EE 7 Specification APIs)

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.