net.sf.xbus.technical.mq
Class MQConnection

java.lang.Object
  extended by net.sf.xbus.technical.mq.MQConnection
All Implemented Interfaces:
TAResource

public class MQConnection
extends java.lang.Object
implements TAResource

MQConnection manages connections and sessions for messagequeues.

It implements two Design-Patterns:

  1. Singleton: An instance of MQConnection is created for every thread. This instance can be fetched with getInstance().
  2. Facade: The complexity of creating and managing a connection is capsuled.


Method Summary
static void clear()
           
 void close()
          Closes the connection.
 void commit()
          Commits all actions on the queues associated with this MQConnection (normally all queues of the current thread).
 javax.jms.TextMessage createTextMessage()
          Creates and returns a JMS- TextMessage.
 javax.jms.QueueBrowser getBrowser(XBUSSystem system)
          Creates and returns a JMS- QueueBrowser for the given queue.
static MQConnection getInstance()
          Delivers an instance of MQConnection.
 java.lang.String getPhysQueuename(XBUSSystem system)
          Reads the name of the message queue from the configuration.
 javax.jms.QueueReceiver getReceiver(XBUSSystem system)
          Creates and returns a JMS- QueueReceiver for the given queue.
 javax.jms.QueueSender getSender(XBUSSystem system)
          Creates and returns a JMS- QueueSender for the given queue.
 void initialize()
          Initializes the MQConnection.
 void open()
          Opens the JMS-QueueSession and JMS-QueueConnection for sending and receiving messages.
 void rollback()
          Performs a rollback for all actions on the queues associated with this MQConnection (normally all queues of the current thread).
protected  void setDeleteInformation(XBUSSystem source, java.lang.String messageId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

open

public void open()
          throws XException
Opens the JMS-QueueSession and JMS-QueueConnection for sending and receiving messages.

Specified by:
open in interface TAResource
Throws:
XException - if something goes wrong

getInstance

public static MQConnection getInstance()
                                throws XException
Delivers an instance of MQConnection.

If it is the first call for the actual thread, a new MQConnection -object gets created. Subsequent calls in this thread will deliver the object, that has been created by the first call.

Throws:
XException

commit

public void commit()
            throws XException
Commits all actions on the queues associated with this MQConnection (normally all queues of the current thread).

Specified by:
commit in interface TAResource
Throws:
XException - if something goes wrong

rollback

public void rollback()
              throws XException
Performs a rollback for all actions on the queues associated with this MQConnection (normally all queues of the current thread).

Specified by:
rollback in interface TAResource
Throws:
XException - if something goes wrong

close

public void close()
           throws XException
Closes the connection.

Specified by:
close in interface TAResource
Throws:
XException - if something goes wrong

initialize

public void initialize()
Initializes the MQConnection.


getSender

public javax.jms.QueueSender getSender(XBUSSystem system)
                                throws XException
Creates and returns a JMS- QueueSender for the given queue.

Throws:
XException

getReceiver

public javax.jms.QueueReceiver getReceiver(XBUSSystem system)
                                    throws XException
Creates and returns a JMS- QueueReceiver for the given queue.

Parameters:
system - name of an interface
Returns:
JMS QueueReceiver
Throws:
XException

getBrowser

public javax.jms.QueueBrowser getBrowser(XBUSSystem system)
                                  throws XException
Creates and returns a JMS- QueueBrowser for the given queue.

Throws:
XException

createTextMessage

public javax.jms.TextMessage createTextMessage()
                                        throws XException
Creates and returns a JMS- TextMessage.

Throws:
XException

setDeleteInformation

protected void setDeleteInformation(XBUSSystem source,
                                    java.lang.String messageId)

clear

public static void clear()

getPhysQueuename

public java.lang.String getPhysQueuename(XBUSSystem system)
                                  throws XException
Reads the name of the message queue from the configuration.

Parameters:
system - the name of the sender/receiver
Returns:
the name of the message queue
Throws:
XException