Package dk.netarkivet.common.distribute
Class JMSConnectionSunMQ
- java.lang.Object
-
- dk.netarkivet.common.distribute.JMSConnection
-
- 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
Fields Modifier and Type Field Description 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.static java.lang.String[]
RECONNECT_ERRORCODES
-
Fields inherited from class dk.netarkivet.common.distribute.JMSConnection
closeHook, connection, connectionLock, CONSUMER_KEY_SEPARATOR, consumers, instance, listeners, producers, session
-
-
Constructor Summary
Constructors Constructor Description JMSConnectionSunMQ()
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Reset the singleton and close the connection by calling super().protected com.sun.messaging.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.javax.jms.QueueSession
getQueueSession()
Provides a QueueSession instance.void
onException(javax.jms.JMSException e)
Exceptionhandler for the JMSConnection.-
Methods inherited from class dk.netarkivet.common.distribute.JMSConnection
createQueueBrowser, createQueueBrowser, getConsumerKey, initConnection, reconnect, removeListener, reply, resend, send, sendMessage, setListener, unpack
-
-
-
-
Field Detail
-
RECONNECT_ERRORCODES
public static final java.lang.String[] RECONNECT_ERRORCODES
-
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.
-
-
Constructor Detail
-
JMSConnectionSunMQ
public JMSConnectionSunMQ()
Constructor.
-
-
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 com.sun.messaging.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 classJMSConnection
- 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 classJMSConnection
- 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 interfaceCleanupIF
- Overrides:
cleanup
in classJMSConnection
-
onException
public void onException(javax.jms.JMSException e)
Exceptionhandler for the JMSConnection. Will try to reconnect on errors with error codes defined in the constant RECONNECT_ERRORCODES.- Specified by:
onException
in interfacejavax.jms.ExceptionListener
- Specified by:
onException
in classJMSConnection
- Parameters:
e
- an JMSException
-
getQueueSession
public javax.jms.QueueSession getQueueSession() throws javax.jms.JMSException
Description copied from class:JMSConnection
Provides a QueueSession instance. Functionality for retrieving aQueueSession
object isen't available on the genericJMSConnectionFactory
- Specified by:
getQueueSession
in classJMSConnection
- Returns:
- A
QueueSession
object connected to the current JMS broker - Throws:
javax.jms.JMSException
- Failure to retrieve theQueueBrowser
JMS Browser
-
-