Movatterモバイル変換


[0]ホーム

URL:


         


Interface TopicSession

All Superinterfaces:
java.lang.Runnable,Session

public interfaceTopicSession
extendsSession

ATopicSession object provides methods for creatingTopicPublisher,TopicSubscriber, andTemporaryTopic objects. It also provides a method for deleting its client's durable subscribers.

See Also:
Session,TopicConnection.createTopicSession(boolean, int),XATopicSession.getTopicSession()

Fields inherited from interface javax.jms.Session
AUTO_ACKNOWLEDGE,CLIENT_ACKNOWLEDGE,DUPS_OK_ACKNOWLEDGE
 
createDurableSubscriber(Topic topic, java.lang.String name)
          Creates a durable subscriber to the specified topic.
createDurableSubscriber(Topic topic, java.lang.String name, java.lang.String messageSelector, boolean noLocal)
          Creates a durable subscriber to the specified topic, using a message selector or specifying whether messages published by its own connection should be delivered to it.
createPublisher(Topic topic)
          Creates a publisher for the specified topic.
createSubscriber(Topic topic)
          Creates a nondurable subscriber to the specified topic.
createSubscriber(Topic topic, java.lang.String messageSelector, boolean noLocal)
          Creates a nondurable subscriber to the specified topic, using a message selector or specifying whether messages published by its own connection should be delivered to it.
createTemporaryTopic()
          Creates aTemporaryTopic object.
createTopic(java.lang.String topicName)
          Creates a topic identity given aTopic name.
unsubscribe(java.lang.String name)
          Unsubscribes 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,run,setMessageListener
 

createTopic

publicTopiccreateTopic(java.lang.String topicName)                  throwsJMSException
Creates a topic identity given aTopic name.

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

Note that this method is not for creating the physical topic. The physical creation of topics is an administrative task and is not to be initiated by the JMS API. The one exception is the creation of temporary topics, which is accomplished with thecreateTemporaryTopic method.

Parameters:
topicName - the name of thisTopic
Returns:
aTopic with the given name
Throws:
JMSException - if the session fails to create a topic due to some internal error.

createSubscriber

publicTopicSubscribercreateSubscriber(Topic topic)                                 throwsJMSException
Creates a nondurable subscriber to the specified topic.

A client uses aTopicSubscriber object to receive messages that have been published to a topic.

RegularTopicSubscriber objects are not durable. They receive only messages that are published while they are active.

In some cases, a connection may both publish and subscribe to a topic. The subscriberNoLocal 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 - theTopic to subscribe to
Throws:
JMSException - if the session fails to create a subscriber due to some internal error.
InvalidDestinationException - if an invalid topic is specified.

createSubscriber

publicTopicSubscribercreateSubscriber(Topic topic,                                        java.lang.String messageSelector,                                        boolean noLocal)                                 throwsJMSException
Creates a nondurable subscriber to the specified topic, using a message selector or specifying whether messages published by its own connection should be delivered to it.

A client uses aTopicSubscriber object to receive messages that have been published to a topic.

RegularTopicSubscriber 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 subscriberNoLocal 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 - theTopic to subscribe to
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
noLocal - if set, inhibits the delivery of messages published by its own connection
Throws:
JMSException - if the session fails to create a subscriber due to some internal error.
InvalidDestinationException - if an invalid topic is specified.
InvalidSelectorException - if the message selector is invalid.

createDurableSubscriber

publicTopicSubscribercreateDurableSubscriber(Topic topic,                                               java.lang.String name)                                        throwsJMSException
Creates 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 durableTopicSubscriber. 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 aTopicSubscriber for a particular durable subscription.

A client can change an existing durable subscription by creating a durableTopicSubscriber with the same name and a new topic and/or message selector. Changing a durable subscriber is equivalent to unsubscribing (deleting) the old one and creating a new one.

In some cases, a connection may both publish and subscribe to a topic. The subscriberNoLocal 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 non-temporaryTopic to subscribe to
name - the name used to identify this subscription
Throws:
JMSException - if the session fails to create a subscriber due to some internal error.
InvalidDestinationException - if an invalid topic is specified.

createDurableSubscriber

publicTopicSubscribercreateDurableSubscriber(Topic topic,                                               java.lang.String name,                                               java.lang.String messageSelector,                                               boolean noLocal)                                        throwsJMSException
Creates a durable subscriber to the specified topic, using a message selector or specifying whether messages published by its own connection should be delivered to it.

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 durableTopicSubscriber. 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 which uniquely identifies (within client identifier) each durable subscription it creates. Only one session at a time can have aTopicSubscriber for a particular durable subscription. An inactive durable subscriber is one that exists but does not currently have a message consumer associated with it.

A client can change an existing durable subscription by creating a durableTopicSubscriber with the same name and a new topic and/or message selector. Changing a durable subscriber is equivalent to unsubscribing (deleting) the old one and creating a new one.

Parameters:
topic - the non-temporaryTopic to subscribe to
name - the name used to identify this subscription
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
noLocal - if set, inhibits the delivery of messages published by its own connection
Throws:
JMSException - if the session fails to create a subscriber due to some internal error.
InvalidDestinationException - if an invalid topic is specified.
InvalidSelectorException - if the message selector is invalid.

createPublisher

publicTopicPublishercreatePublisher(Topic topic)                               throwsJMSException
Creates a publisher for the specified topic.

A client uses aTopicPublisher object to publish messages on a topic. Each time a client creates aTopicPublisher on a topic, it defines a new sequence of messages that have no ordering relationship with the messages it has previously sent.

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

createTemporaryTopic

publicTemporaryTopiccreateTemporaryTopic()                                    throwsJMSException
Creates aTemporaryTopic object. Its lifetime will be that of theTopicConnection unless it is deleted earlier.
Returns:
a temporary topic identity
Throws:
JMSException - if the session fails to create a temporary topic due to some internal error.

unsubscribe

public voidunsubscribe(java.lang.String name)                 throwsJMSException
Unsubscribes a durable subscription that has been created by a client.

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

It is erroneous for a client to delete a durable subscription while there is an activeTopicSubscriber for the subscription, or while a consumed message is part of a pending transaction or has not been acknowledged in the session.

Parameters:
name - the name used to identify this subscription
Throws:
JMSException - if the session fails to unsubscribe to the durable subscription due to some internal error.
InvalidDestinationException - if an invalid subscription name is specified.

         


[8]ページ先頭

©2009-2025 Movatter.jp