javax.jms
Interface TopicPublisher


public interface TopicPublisher
extends MessageProducer

A client uses a TopicPublisher for publishing messages on a topic. TopicPublisher is the Pub/Sub variant of a JMS message producer.

Normally the Topic is specified when a TopicPublisher is created and in this case, attempting to use the methods for an unidentified TopicPublisher will throws an UnsupportedOperationException.

In the case that the TopicPublisher with an unidentified Topic is created, the methods that assume the Topic has been identified throw an UnsupportedOperationException.

See Also:
TopicSession.createPublisher(Topic)

Method Summary
 Topic getTopic()
          Get the topic associated with this publisher.
 void publish(Message message)
          Publish a Message to the topic Use the topics default delivery mode, timeToLive and priority.
 void publish(Message message, int deliveryMode, int priority, long timeToLive)
          Publish a Message to the topic specifying delivery mode, priority and time to live to the topic.
 void publish(Topic topic, Message message)
          Publish a Message to a topic for an unidentified message producer.
 void publish(Topic topic, Message message, int deliveryMode, int priority, long timeToLive)
          Publish a Message to a topic for an unidentified message producer, specifying delivery mode, priority and time to live.
 
Methods inherited from interface javax.jms.MessageProducer
close, getDeliveryMode, getDisableMessageID, getDisableMessageTimestamp, getPriority, getTimeToLive, setDeliveryMode, setDisableMessageID, setDisableMessageTimestamp, setPriority, setTimeToLive
 

Method Detail

getTopic

public Topic getTopic()
               throws JMSException
Get the topic associated with this publisher.
Returns:
this publisher's topic
Throws:
JMSException - if JMS fails to get topic for this topic publisher due to some internal error.

publish

public void publish(Message message)
             throws JMSException
Publish a Message to the topic Use the topics default delivery mode, timeToLive and priority.
Parameters:
message - the message to publish
Throws:
JMSException - if JMS fails to publish the message due to some internal error.
MessageFormatException - if invalid message specified
InvalidDestinationException - if a client uses this method with a Topic Publisher with an invalid topic.

publish

public void publish(Message message,
                    int deliveryMode,
                    int priority,
                    long timeToLive)
             throws JMSException
Publish a Message to the topic specifying delivery mode, priority and time to live to the topic.
Parameters:
message - the message to publish
deliveryMode - the delivery mode to use
priority - the priority for this message
timeToLive - the message's lifetime (in milliseconds).
Throws:
JMSException - if JMS fails to publish the message due to some internal error.
MessageFormatException - if invalid message specified
InvalidDestinationException - if a client uses this method with a Topic Publisher with an invalid topic.

publish

public void publish(Topic topic,
                    Message message)
             throws JMSException
Publish a Message to a topic for an unidentified message producer. Use the topics default delivery mode, timeToLive and priority.

Typically a JMS message producer is assigned a topic at creation time; however, JMS also supports unidentified message producers which require that the topic be supplied on every message publish.

Parameters:
topic - the topic to publish this message to
message - the message to send
Throws:
JMSException - if JMS fails to publish the message due to some internal error.
MessageFormatException - if invalid message specified
InvalidDestinationException - if a client uses this method with an invalid topic.

publish

public void publish(Topic topic,
                    Message message,
                    int deliveryMode,
                    int priority,
                    long timeToLive)
             throws JMSException
Publish a Message to a topic for an unidentified message producer, specifying delivery mode, priority and time to live.

Typically a JMS message producer is assigned a topic at creation time; however, JMS also supports unidentified message producers which require that the topic be supplied on every message publish.

Parameters:
topic - the topic to publish 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:
JMSException - if JMS fails to publish the message due to some internal error.
MessageFormatException - if invalid message specified
InvalidDestinationException - if a client uses this method with an invalid topic.