dk.netarkivet.common.distribute
Class JMSConnectionSunMQ

java.lang.Object
  extended by dk.netarkivet.common.distribute.JMSConnection
      extended by dk.netarkivet.common.distribute.JMSConnectionSunMQ
All Implemented Interfaces:
CleanupIF, javax.jms.ExceptionListener

public class JMSConnectionSunMQ
extends JMSConnection

Handles the communication with a Sun JMS broker. Note on Thread-safety: the methods and fields of JMSConnection are not accessed by multiple threads (though JMSConnection itself creates threads). Thus no synchronization is needed on methods and fields of JMSConnection. A shutdown hook is also added, which closes the connection. The warnings and errorcodes reported by Sun Message Queue 4.1 can be found in Appendix A Sun Java System Message Queue 4.1 Developer's Guide for Java Clients: http://docs.sun.com/app/docs/doc/819-7757/aeqgo?a=view


Field Summary
protected static JMSConnectionSunMQ instance
          Singleton pattern is be used for this class.
(package private) static java.lang.String PACKET_ACK_FAILED
          The errorcode for failure of the JMSbroker to acknowledge a message.
(package private) static java.lang.String RECEIVED_GOODBYE_FROM_BROKER
          The errorcode signifying that the JMSbroker has been shutdown.
(package private) static java.lang.String SESSION_IS_CLOSED
          The errorcode signifying that the current session to the JMSbroker has been closed by the jmsbroker.
 
Fields inherited from class dk.netarkivet.common.distribute.JMSConnection
CONSUMER_KEY_SEPARATOR, consumers, JMS_MAXTRIES, log, myQConn, myQConnFactory, myQSess, myTConn, myTConnFactory, myTSess, publishers, reconnectInProgress, senders
 
Method Summary
 void cleanup()
          Close the connection and reset the singleton
static JMSConnectionSunMQ getInstance()
          Intialises an Open Message Queue JMS connection.
protected  javax.jms.Queue getQueue(java.lang.String queueName)
          Returns an Queue.
protected  com.sun.messaging.QueueConnectionFactory getQueueConnectionFactory()
          Returns a new QueueConnectionFactory.
protected  javax.jms.Topic getTopic(java.lang.String topicName)
          Returns an Topic.
protected  com.sun.messaging.TopicConnectionFactory getTopicConnectionFactory()
          Returns a new TopicConnectionFactory.
 void onException(javax.jms.JMSException e)
          Exceptionhandler for the JMSConnection.
 
Methods inherited from class dk.netarkivet.common.distribute.JMSConnection
close, establishConnectionAndSessions, getChannelName, getHost, getPort, initConnection, removeAllMessages, removeListener, reply, resend, send, sendMessage, setListener, unpack
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

protected static JMSConnectionSunMQ instance
Singleton pattern is be used for this class. This is the one and only instance.


PACKET_ACK_FAILED

static final java.lang.String PACKET_ACK_FAILED
The errorcode for failure of the JMSbroker to acknowledge a message.

See Also:
Constant Field Values

SESSION_IS_CLOSED

static final java.lang.String SESSION_IS_CLOSED
The errorcode signifying that the current session to the JMSbroker has been closed by the jmsbroker. One of the reasons: that the JMSbroker has been shutdown previously.

See Also:
Constant Field Values

RECEIVED_GOODBYE_FROM_BROKER

static final java.lang.String RECEIVED_GOODBYE_FROM_BROKER
The errorcode signifying that the JMSbroker has been shutdown. This errorcode is issued by the JMS-client.

See Also:
Constant Field Values
Method Detail

getInstance

public static JMSConnectionSunMQ getInstance()
                                      throws UnknownID,
                                             IOFailure
Intialises an Open Message Queue JMS connection.

Returns:
A JMSConnection
Throws:
IOFailure - when connection to JMS broker failed
UnknownID

getQueueConnectionFactory

protected com.sun.messaging.QueueConnectionFactory getQueueConnectionFactory()
                                                                      throws javax.jms.JMSException
Returns a new QueueConnectionFactory. This is an SunMQ implementation of QueueConnectionFactory. Notice: The return type is explicitly defined with package prefix to avoid name collision with javax.jms.QueueConnectionFactory

Specified by:
getQueueConnectionFactory in class JMSConnection
Returns:
QueueConnectionFactory
Throws:
javax.jms.JMSException

getTopicConnectionFactory

protected com.sun.messaging.TopicConnectionFactory getTopicConnectionFactory()
                                                                      throws javax.jms.JMSException
Returns a new TopicConnectionFactory. This is an SunMQ implementation of TopicConnectionFactory. Notice: The return type is explicitly defined with package prefix to avoid name collision with javax.jms.TopicConnectionFactory

Specified by:
getTopicConnectionFactory in class JMSConnection
Returns:
TopicConnectionFactory
Throws:
javax.jms.JMSException

getQueue

protected javax.jms.Queue getQueue(java.lang.String queueName)
                            throws javax.jms.JMSException
Returns an Queue. This is an SunMQ implementation of Queue. If no queue exists a new one will be created.

Specified by:
getQueue in class JMSConnection
Parameters:
queueName - the name of the queue.
Returns:
Queue
Throws:
javax.jms.JMSException

getTopic

protected javax.jms.Topic getTopic(java.lang.String topicName)
                            throws javax.jms.JMSException
Returns an Topic. This is an SunMQ implementation of Topic. If no topic exists a new one will be created.

Specified by:
getTopic in class JMSConnection
Parameters:
topicName - the name of the topic.
Returns:
Topic
Throws:
javax.jms.JMSException

cleanup

public void cleanup()
Close the connection and reset the singleton

Specified by:
cleanup in interface CleanupIF
Overrides:
cleanup in class JMSConnection

onException

public void onException(javax.jms.JMSException e)
Exceptionhandler for the JMSConnection. Only handles exceptions, if reconnectInProgress is false. Only handles exceptions with errorcodes PACKET_ACK_FAILED, SESSION_IS_CLOSED, and RECEIVED_GOODBYE_FROM_BROKER.

Specified by:
onException in interface javax.jms.ExceptionListener
Specified by:
onException in class JMSConnection
Parameters:
e - an JMSException