Arch4J 1.1

org.arch4j.messaging
Class MessageQueueFacade

java.lang.Object
  |
  +--org.arch4j.messaging.MessageFacade
        |
        +--org.arch4j.messaging.MessageQueueFacade
Direct Known Subclasses:
WebLogicMessageQueueFacade, WebsphereMessageQueueFacade

public abstract class MessageQueueFacade
extends MessageFacade

This class provides clients with a simplified and provider-independent interface to JMS message queues. It is not intended to be a full wrapper around JMS functionality. An instance of this class represents a single QueueSession. The class gives access to queue browsers, receivers, and senders as well as the queue connection factory, the queue session, existing queues, and new messages.

As an example of using the message queue facade:

MessageQueueFacade qFacade = MessagingProvider.getProvider().getMessageQueueFacade(false);

QueueSender sender = qFacade.createQueueSender("exampleQueue");

qFacade.startConnection();

TextMessage message = qFacade.createTextMessage(new StringBuffer("Hello Whirled"));

sender.send(message);

sender.close();

qFacade.close();

Version:
1.0
Author:
David Colwell

Constructor Summary
protected MessageQueueFacade()
          Constructs an instance of MessageQueueFacade.
 
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.
static void closeConnection()
          Close the static queue Connection.
 javax.jms.QueueBrowser createQueueBrowser(String queueName, String messageSelector)
          Create a QueueBrowser.
 javax.jms.QueueReceiver createQueueReciever(String queueName, String messageSelector)
          Create a QueueBrowser.
 javax.jms.QueueSender createQueueSender(String queueName)
          Create a QueueSender.
 javax.jms.QueueConnection getQueueConnection()
          Returns a reference to the QueueConnection instance.
protected abstract  javax.jms.QueueConnectionFactory getQueueConnectionFactory()
          Interface method to retrieve a QueueConnectionFactory.
 javax.jms.QueueSession getQueueSession()
          Returns a reference to the QueueSession instance associated with this object.
protected  javax.jms.Session getSession()
          Returns a Session reference to the QueueSession instance associated with this object.
protected  void initialize(boolean isTransactional)
          Initialize the new instance.
protected  void initialize(boolean isTransactional, int acknowledgeMode)
          Initialize the new instance.
abstract  javax.jms.Queue lookupQueue(String queueName)
          Interface method to retrieve a Queue.
 void startConnection()
          Start (or restart) a Connection's delivery of incoming messages.
 
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

MessageQueueFacade

protected MessageQueueFacade()
Constructs an instance of MessageQueueFacade. 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

protected 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 queueConnection here as other Sessions may be relying on it.


closeConnection

public static void closeConnection()
Close the static queue Connection. To be used on application exit to make sure the connections are all closed.


getQueueConnectionFactory

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


lookupQueue

public abstract javax.jms.Queue lookupQueue(String queueName)
Interface method to retrieve a Queue. Details of retrieval are implementation specific.

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

getQueueSession

public javax.jms.QueueSession getQueueSession()
Returns a reference to the QueueSession instance associated with this object.


getSession

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

Specified by:
getSession in class MessageFacade

getQueueConnection

public javax.jms.QueueConnection getQueueConnection()
Returns a reference to the QueueConnection instance.


createQueueBrowser

public javax.jms.QueueBrowser createQueueBrowser(String queueName,
                                                 String messageSelector)
Create a QueueBrowser. If the messageSelector is null then the QueueBrowser is created with no message selector. Assumes that the queue specified exists, if not a EnvironmentalException is thrown.

Returns:
the QueueBrowser

createQueueReciever

public javax.jms.QueueReceiver createQueueReciever(String queueName,
                                                   String messageSelector)
Create a QueueBrowser. If the messageSelector is null then the QueueBrowser is created with no message selector. Assumes that the queue specified exists, if not a EnvironmentalException is thrown.

Returns:
the QueueReceiver

createQueueSender

public javax.jms.QueueSender createQueueSender(String queueName)
Create a QueueSender. Assumes that the queue specified exists, if not a EnvironmentalException is thrown.

Returns:
the QueueSender

Arch4J 1.1

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