Arch4J 1.1

org.arch4j.messaging
Class MessageTopicFacade

java.lang.Object
  |
  +--org.arch4j.messaging.MessageFacade
        |
        +--org.arch4j.messaging.MessageTopicFacade
Direct Known Subclasses:
WebLogicMessageTopicFacade, WebsphereMessageTopicFacade

public abstract class MessageTopicFacade
extends MessageFacade

This class provides clients with a simplified and provider-independent interface to JMS message topics. It is not intended to be a full wrapper around JMS functionality. An instance of this class represents a single TopicSession. The class gives access to topic publishers, subscribers, and durable subscribers as well as the topic connection, the topic session, existing topics, and new messages.

As an example of using the message topic facade:

MessageTopicFacade tFacade = MessagingProvider.getProvider().getMessageTopicFacade(false);

TopicSubscriber subscriber = tFacade.createTopicSubscriber("exampleTopic");

subscriber.setMessageListener(this);

tFacade.startConnection();

...

subscriber.close();

tFacade.close();

Version:
1.0
Author:
David Colwell

Constructor Summary
protected MessageTopicFacade()
          Constructs an instance of MessageTopicFacade.
 
Method Summary
 void close()
          Since a provider typically allocates resources outside the JVM on behalf of a Session, clients should close them when they are not needed.
 javax.jms.TopicSubscriber createDurableTopicSubscriber(String topicName, String subscriptionID)
          Create a durable TopicSubscriber using the session instance associated with this facade.
 javax.jms.TopicSubscriber createDurableTopicSubscriber(String topicName, String subscriptionID, String messageSelector, boolean noLocal)
          Create a durable TopicSubscriber using the session instance associated with this facade.
 javax.jms.TopicPublisher createTopicPublisher(String topicName)
          Create a TopicPublisher using the session instance associated with this facade.
 javax.jms.TopicSubscriber createTopicSubscriber(String topicName)
          Create a TopicSubscriber using the session instance associated with this facade.
 javax.jms.TopicSubscriber createTopicSubscriber(String topicName, String messageSelector, boolean noLocal)
          Create a TopicSubscriber with the specified message selector and local message filter specifier using the session instance associated with this facade.
protected  javax.jms.Session getSession()
          Returns a Session reference to the TopicSession instance associated with this object.
 javax.jms.TopicConnection getTopicConnection()
          Returns a reference to the TopicConnection instance.
protected abstract  javax.jms.TopicConnectionFactory getTopicConnectionFactory()
          Interface method to retrieve a TopicConnectionFactory.
 javax.jms.TopicSession getTopicSession()
          Returns a reference to the TopicSession associated with this object.
 void initialize(boolean isTransactional)
          Initialize the new instance.
protected  void initialize(boolean isTransactional, int acknowledgeMode)
          Initialize the new instance.
abstract  javax.jms.Topic lookupTopic(String topicName)
          Interface method to retrieve a Topic.
 void startConnection()
          Start (or restart) a Connection's delivery of incoming messages.
 void unsubscribeDurableSubscription(String subscriptionID)
          Unsubscribe the durable subscription named by the subscriptionID.
 
Methods inherited from class org.arch4j.messaging.MessageFacade
commit, createBytesMessage, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createStreamMessage, createTextMessage, createTextMessage, rollback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageTopicFacade

protected MessageTopicFacade()
Constructs an instance of MessageTopicFacade. It is a protected method as the only class who should instantiate this is MessagingProvider.

Method Detail

initialize

protected void initialize(boolean isTransactional,
                          int acknowledgeMode)
Initialize the new instance. This method must be called by the MessagingProvider.


initialize

public void initialize(boolean isTransactional)
Initialize the new instance. This method must be called by the MessagingProvider.


startConnection

public void startConnection()
Start (or restart) a Connection's delivery of incoming messages. Restart begins with the oldest unacknowledged message. Starting a started session is ignored.


close

public void close()
Since a provider typically allocates resources outside the JVM on behalf of a Session, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough. Note: Do not close the static topicConnection here as other Sessions may be relying on it.


getTopicConnectionFactory

protected abstract javax.jms.TopicConnectionFactory getTopicConnectionFactory()
Interface method to retrieve a TopicConnectionFactory. Details of retrieval are implementation specific.


lookupTopic

public abstract javax.jms.Topic lookupTopic(String topicName)
Interface method to retrieve a Topic. Details of retrieval are implementation specific.

Returns:
The Topic, if it exists. Otherwise, null.

getTopicSession

public javax.jms.TopicSession getTopicSession()
Returns a reference to the TopicSession associated with this object.


getSession

protected javax.jms.Session getSession()
Returns a Session reference to the TopicSession instance associated with this object. Implements the abstract superclass method.

Specified by:
getSession in class MessageFacade

getTopicConnection

public javax.jms.TopicConnection getTopicConnection()
Returns a reference to the TopicConnection instance.


createTopicPublisher

public javax.jms.TopicPublisher createTopicPublisher(String topicName)
Create a TopicPublisher using the session instance associated with this facade.


createDurableTopicSubscriber

public javax.jms.TopicSubscriber createDurableTopicSubscriber(String topicName,
                                                              String subscriptionID)
Create a durable TopicSubscriber using the session instance associated with this facade.

Parameters:
topicName - The name of the topic to associate the subscriber with.
subscriptionID - The name used to identify this subscription.

createDurableTopicSubscriber

public javax.jms.TopicSubscriber createDurableTopicSubscriber(String topicName,
                                                              String subscriptionID,
                                                              String messageSelector,
                                                              boolean noLocal)
Create a durable TopicSubscriber using the session instance associated with this facade.

Parameters:
topicName - The name of the topic to associate the subscriber with.
subscriptionID - 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.

createTopicSubscriber

public javax.jms.TopicSubscriber createTopicSubscriber(String topicName)
Create a TopicSubscriber using the session instance associated with this facade.

Parameters:
topicName - The name of the topic to associate the subscriber with.

createTopicSubscriber

public javax.jms.TopicSubscriber createTopicSubscriber(String topicName,
                                                       String messageSelector,
                                                       boolean noLocal)
Create a TopicSubscriber with the specified message selector and local message filter specifier using the session instance associated with this facade.

Parameters:
topicName - The name of the topic to associate the subscriber with.
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.

unsubscribeDurableSubscription

public void unsubscribeDurableSubscription(String subscriptionID)
Unsubscribe the durable subscription named by the subscriptionID. This deletes the state being maintained on behalf of the subscriber by its provider.

Parameters:
subscriptionID - The name used to identify this subscription.

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.