TopicSession


public interface TopicSession
extends Session

WebSphere MQ class: MQTopicSession



java.lang.Object
   |
   +----com.ibm.mq.jms.MQSession
           |
           +----com.ibm.mq.jms.MQTopicSession

A TopicSession provides methods for creating TopicPublishers, TopicSubscribers and TemporaryTopics.

See also: Session

WebSphere MQ constructor

MQTopicSession
public MQTopicSession(boolean transacted,
                      int acknowledgeMode) throws JMSException

See TopicConnection.createTopicSession.

Methods

createDurableSubscriber
public TopicSubscriber createDurableSubscriber
                           (Topic topic,
                            java.lang.String name) throws JMSException

Create a durable subscriber to the specified topic.

WebSphere MQ Event Broker note

This method throws a JMSException when you have a direct connection to WebSphere MQ Event Broker.

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 because of a JMS error.
  • InvalidDestinationException - if the Topic specified is not valid.

See TopicSession.unsubscribe

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. A client can change an existing durable subscription by creating a durable subscriber with the same name and a new topic or message selector or both.

WebSphere MQ Event Broker note

This method throws a JMSException when you have a direct connection to WebSphere MQ Event Broker.

Parameters:
  • topic - the topic to subscribe to.
  • name - the name used to identify this subscription.
  • messageSelector - only messages with properties that match 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 because of a JMS error or non valid selector.
  • InvalidDestinationException - if the Topic specified is not valid.
  • InvalidSelectorException - if the message selector is not valid.

createPublisher
public TopicPublisher createPublisher(Topic topic)
                                    throws JMSException

Create a Publisher for the specified Topic.

Parameters:
topic - the topic to publish to, or null if this is an unidentified producer.

Throws:
  • JMSException - if a session fails to create a publisher because of a JMS error.
  • InvalidDestinationException - if the Topic specified is not valid.

createSubscriber
public TopicSubscriber createSubscriber(Topic topic)
                                         throws JMSException

Create a non-durable subscriber to the specified topic.

Parameters:
topic - the topic to subscribe to

Throws:
  • JMSException - if a session fails to create a subscriber because of a JMS error.
  • InvalidDestinationException - if the Topic specified is not valid.

createSubscriber
public TopicSubscriber createSubscriber
                             (Topic topic,
                              java.lang.String messageSelector,
                              boolean noLocal) throws JMSException

Create a non-durable subscriber to the specified topic.

Parameters:
  • topic - the topic to subscribe to.
  • messageSelector - only messages with properties that match 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 because of a JMS error or non valid selector.
  • InvalidDestinationException - if the Topic specified is not valid.
  • InvalidSelectorException - if the message selector is not valid.

createTemporaryTopic
public TemporaryTopic createTemporaryTopic()
                                      throws JMSException

Create a temporary topic. Its 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 because of a JMS error.

createTopic
public Topic createTopic(java.lang.String topicName)
                                             throws JMSException

Create a Topic given a URI format Topic name. (URI format is described in Creating topics at runtime.) This allows the creation of a topic with a provider specific name.

Note:
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 because of a JMS error.

unsubscribe
public void unsubscribe(java.lang.String name)
                                       throws JMSException

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

WebSphere MQ Event Broker note

This method throws a JMSException when you have a direct connection to WebSphere MQ Event Broker.

Note:
Do not use this method while an active subscription exists. You must close() your subscriber first.

Parameters:
name - the name used to identify this subscription.

Throws:
  • JMSException - if JMS fails to unsubscribe the durable subscription because of a JMS error.
  • InvalidDestinationException - if the subscription name specified is not valid.



© IBM Corporation 1997, 2002. All Rights Reserved