Class TopicPublisher

  • All Implemented Interfaces:
    jakarta.jms.MessageProducer, jakarta.jms.TopicPublisher, AutoCloseable

    public class TopicPublisher
    extends MessageProducer
    implements jakarta.jms.TopicPublisher
    Implements the jakarta.jms.TopicPublisher interface.
    • Constructor Detail

      • TopicPublisher

        TopicPublisher​(TopicSession sess,
                       Destination topic)
                throws jakarta.jms.JMSException
        Constructs a publisher.
        Parameters:
        sess - The session the publisher belongs to.
        topic - The topic the publisher publishs messages on.
        Throws:
        jakarta.jms.IllegalStateException - If the connection is broken.
        jakarta.jms.JMSException - If the creation fails for any other reason.
    • Method Detail

      • toString

        public String toString()
        Returns a string view of this receiver.
        Overrides:
        toString in class Object
      • getTopic

        public jakarta.jms.Topic getTopic()
                                   throws jakarta.jms.JMSException
        API method. Gets the topic associated with this topic publisher.
        Specified by:
        getTopic in interface jakarta.jms.TopicPublisher
        Returns:
        this publisher's topic.
        Throws:
        jakarta.jms.IllegalStateException - If the publisher is closed.
        jakarta.jms.JMSException
      • publish

        public void publish​(jakarta.jms.Message message,
                            int deliveryMode,
                            int priority,
                            long timeToLive)
                     throws jakarta.jms.JMSException
        API method. Sends a message to a topic with default delivery parameters.
        Specified by:
        publish in interface jakarta.jms.TopicPublisher
        Parameters:
        message - the message to send.
        deliveryMode - the delivery mode to use.
        priority - the priority for this message.
        timeToLive - the message's lifetime in milliseconds.
        Throws:
        jakarta.jms.IllegalStateException - If the publisher is closed, or if the connection is broken.
        jakarta.jms.JMSException - If the request fails for any other reason.
      • publish

        public void publish​(jakarta.jms.Message message)
                     throws jakarta.jms.JMSException
        API method. Sends a message to a topic with default delivery parameters.
        Specified by:
        publish in interface jakarta.jms.TopicPublisher
        Parameters:
        message - the message to send.
        Throws:
        jakarta.jms.IllegalStateException - If the publisher is closed, or if the connection is broken.
        jakarta.jms.JMSException - If the request fails for any other reason.
      • publish

        public void publish​(jakarta.jms.Topic topic,
                            jakarta.jms.Message message)
                     throws jakarta.jms.JMSException
        API method. Sends a message to a topic for an unidentified topic publisher with default delivery parameters.

        Typically, a topic publisher is assigned a topic at creation time; however, the JMS API also supports unidentified topic publisher, which require that the topic be supplied every time a message is sent.

        Specified by:
        publish in interface jakarta.jms.TopicPublisher
        Parameters:
        topic - the topic to send this message to.
        message - the message to send.
        Throws:
        jakarta.jms.IllegalStateException - If the publisher is closed, or if the connection is broken.
        jakarta.jms.JMSException - If the request fails for any other reason.
      • publish

        public void publish​(jakarta.jms.Topic topic,
                            jakarta.jms.Message message,
                            int deliveryMode,
                            int priority,
                            long timeToLive)
                     throws jakarta.jms.JMSException
        API method. Sends a message to a topic for an unidentified topic publisher with given delivery parameters.

        Typically, a topic publisher is assigned a topic at creation time; however, the JMS API also supports unidentified topic publisher, which require that the topic be supplied every time a message is sent.

        Specified by:
        publish in interface jakarta.jms.TopicPublisher
        Parameters:
        topic - the topic to send this message to.
        message - the message to send.
        deliveryMode - the delivery mode to use.
        priority - the priority for this message.
        timeToLive - the message's lifetime in milliseconds.
        Throws:
        jakarta.jms.IllegalStateException - If the publisher is closed, or if the connection is broken.
        jakarta.jms.JMSException - If the request fails for any other reason.