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. Methods are implemented to get a connection, as well as queues and topics. The error handling will try to reconnect on given error scenarios. 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
static java.lang.String JMS_BROKER_HOST
          settings.common.jms.broker:
The JMS broker host contacted by the JMS connection.
static java.lang.String JMS_BROKER_PORT
          settings.common.jms.port:
The port the JMS connection should use.
(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 READ_PACKET_FAILED
          The errorcode for failure to fread from a JMS connection.
(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.
(package private) static java.lang.String WRITE_PACKET_FAILED
          The errorcode for failure to write to a JMS connection.
 
Fields inherited from class dk.netarkivet.common.distribute.JMSConnection
closeHook, connection, CONSUMER_KEY_SEPARATOR, consumers, instance, JMS_MAXTRIES, myQSess, myTSess, producers, reconnectInProgress
 
Method Summary
 void cleanup()
          Reset the singleton and close the connection by calling super().
protected  javax.jms.ConnectionFactory getConnectionFactory()
          Returns a new QueueConnectionFactory.
protected  javax.jms.Destination getDestination(java.lang.String channelName)
          Returns an Queue or a Topic.
static JMSConnection getInstance()
          Intialises an Open Message Queue JMS connection.
 void onException(javax.jms.JMSException e)
          Exceptionhandler for the JMSConnection.
 
Methods inherited from class dk.netarkivet.common.distribute.JMSConnection
getConsumerKey, initConnection, reconnect, 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

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

WRITE_PACKET_FAILED

static final java.lang.String WRITE_PACKET_FAILED
The errorcode for failure to write to a JMS connection.

See Also:
Constant Field Values

READ_PACKET_FAILED

static final java.lang.String READ_PACKET_FAILED
The errorcode for failure to fread from a JMS connection.

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

JMS_BROKER_HOST

public static java.lang.String JMS_BROKER_HOST
settings.common.jms.broker:
The JMS broker host contacted by the JMS connection.


JMS_BROKER_PORT

public static java.lang.String JMS_BROKER_PORT
settings.common.jms.port:
The port the JMS connection should use.

Method Detail

getInstance

public static JMSConnection getInstance()
                                 throws IOFailure
Intialises an Open Message Queue JMS connection.

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

getConnectionFactory

protected javax.jms.ConnectionFactory getConnectionFactory()
                                                    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:
getConnectionFactory in class JMSConnection
Returns:
QueueConnectionFactory
Throws:
javax.jms.JMSException - If unable to create a QueueConnectionfactory with the necessary properties: imqConsumerflowLimit set to 1, imqBrokerHostname and imqBrokerHostPort set to the values defined in our settings.

getDestination

protected javax.jms.Destination getDestination(java.lang.String channelName)
                                        throws javax.jms.JMSException
Returns an Queue or a Topic. This is an SunMQ implementation of Queue and Topic. The method depends on the JMS provider being configured to autocreate queues and topics.

Specified by:
getDestination in class JMSConnection
Parameters:
channelName - the name of the queue or topic.
Returns:
A queue or topic depending on the channel name.
Throws:
javax.jms.JMSException - If unable to create the destination.

cleanup

public void cleanup()
Reset the singleton and close the connection by calling super().

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, READ_PACKET_FAILED, WRITE_PACKET_FAILED, SESSION_IS_CLOSED, and RECEIVED_GOODBYE_FROM_BROKER. In all these cases, the connection is attempted reestablished.

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