javax.jms
Interface TopicSession


public abstract interface TopicSession
extends Session

A TopicSession provides methods for creating TopicPublisher's, TopicSubscriber's and TemporaryTopics. It also provides a method for deleting its client's durable subscribers.

Version:
1.0 - 4 August 1998
Author:
Mark Hapner, Rich Burridge
See Also:
Session

Fields inherited from class javax.jms.Session
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE
 
Method Summary
 TopicSubscriber createDurableSubscriber(Topic topic, java.lang.String name)
          Create a durable Subscriber to the specified topic.
 TopicSubscriber createDurableSubscriber(Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal)
          Create a durable Subscriber to the specified topic.
 TopicPublisher createPublisher(Topic topic)
          Create a Publisher for the specified topic.
 TopicSubscriber createSubscriber(Topic topic)
          Create a non-durable Subscriber to the specified topic.
 TopicSubscriber createSubscriber(Topic topic, java.lang.String messageSelector, boolean noLocal)
          Create a non-durable Subscriber to the specified topic.
 TemporaryTopic createTemporaryTopic()
          Create a temporary topic.
 Topic createTopic(java.lang.String topicName)
          Create a Topic given a Topic name.
 void unsubscribe(java.lang.String name)
          Unsubscribe a durable subscription that has been created by a client.
 
Methods inherited from interface javax.jms.Session
close, commit, createBytesMessage, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createStreamMessage, createTextMessage, createTextMessage, getMessageListener, getTransacted, recover, rollback, setMessageListener
 
Methods inherited from interface java.lang.Runnable
run
 

Method Detail

createTopic


public Topic createTopic(java.lang.String topicName)

                  throws JMSException
Create a Topic given a Topic name.

This facility is provided for the rare cases where clients need to dynamically manipulate topic identity. This allows the creation of a topic with a provider specific name. Clients that depend on this ability are not portable.

Parameters:
topicName - the name of this topic
Returns:
a Topic with the given name.
Throws:
JMSException - if a session fails to create a topic due to some JMS error.

createSubscriber


public TopicSubscriber createSubscriber(Topic topic)

                                 throws JMSException
Create a non-durable Subscriber to the specified topic.

A client uses a TopicSubscriber for receiving messages that have been published to a topic.

Regular TopicSubscriber's are not durable. They only receive messages that are published while they are active.

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. The default value for this attribute is false.

Parameters:
topic - the topic to subscribe to
Throws:
JMSException - if a session fails to create a subscriber due to some JMS error.
InvalidDestinationException - if invalid Topic specified.

createSubscriber


public TopicSubscriber createSubscriber(Topic topic,

                                        java.lang.String messageSelector,

                                        boolean noLocal)

                                 throws JMSException
Create a non-durable Subscriber to the specified topic.

A client uses a TopicSubscriber for receiving messages that have been published to a topic.

Regular TopicSubscriber's are not durable. They only receive 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 simply don't 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.

Parameters:
topic - the topic to subscribe to
messageSelector - only messages with properties matching the message selector expression are delivered. This value may be null.
noLocal - if set, inhibits the delivery of messages published by its own connection.
Throws:
JMSException - if a session fails to create a subscriber due to some JMS error or invalid selector.
InvalidDestinationException - if invalid Topic specified.
InvalidSelectorException - if the message selector is invalid.

createDurableSubscriber


public TopicSubscriber createDurableSubscriber(Topic topic,

                                               java.lang.String name)

                                        throws JMSException
Create a durable Subscriber to the specified topic.

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. JMS retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are either 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 which 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 subscriber is equivalent to deleting and recreating it

Parameters:
topic - the topic to subscribe to
name - the name used to identify this subscription.
Throws:
JMSException - if a session fails to create a subscriber due to some JMS error.
InvalidDestinationException - if invalid Topic specified.

createDurableSubscriber


public TopicSubscriber createDurableSubscriber(Topic topic,

                                               java.lang.String name,

                                               java.lang.String messageSelector,

                                               boolean noLocal)

                                        throws JMSException
Create a durable Subscriber to the specified topic.

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. JMS retains a record of this durable subscription and insures that all messages from the topic's publishers are retained until they are either 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 which 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 subscriber is equivalent to deleting and recreating it

Parameters:
topic - the topic to subscribe to
name - the name used to identify this subscription.
messageSelector - only messages with properties matching the message selector expression are delivered. This value may be null.
noLocal - if set, inhibits the delivery of messages published by its own connection.
Throws:
JMSException - if a session fails to create a subscriber due to some JMS error or invalid selector.
InvalidDestinationException - if invalid Topic specified.
InvalidSelectorException - if the message selector is invalid.

createPublisher


public TopicPublisher createPublisher(Topic topic)

                               throws JMSException
Create a Publisher for the specified topic.

A client uses a TopicPublisher for publishing messages on a topic. Each time a client creates a TopicPublisher on a topic, it defines a new sequence of messages that have no ordering relationship with the messages it has previously sent.

Parameters:
topic - the topic to publish to, or null if this is an unidentifed producer.
Throws:
JMSException - if a session fails to create a publisher due to some JMS error.
InvalidDestinationException - if invalid Topic specified.

createTemporaryTopic


public TemporaryTopic createTemporaryTopic()

                                    throws JMSException
Create a temporary topic. It's lifetime will be that of the TopicConnection unless deleted earlier.
Returns:
a temporary topic.
Throws:
JMSException - if a session fails to create a temporary topic due to some JMS error.

unsubscribe


public void unsubscribe(java.lang.String name)

                 throws JMSException
Unsubscribe a durable subscription that has been created by a client.

This deletes the state being maintained on behalf of the subscriber by its provider.

Parameters:
name - the name used to identify this subscription.
Throws:
JMSException - if JMS fails to unsubscribe to durable subscription due to some JMS error.
InvalidDestinationException - if invalid Topic specified.