|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdk.netarkivet.common.distribute.JMSConnection
public abstract class JMSConnection
Handles the communication with a 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.
Field Summary | |
---|---|
(package private) static java.lang.String |
CONSUMER_KEY_SEPARATOR
|
protected static org.apache.commons.logging.Log |
log
|
Constructor Summary | |
---|---|
protected |
JMSConnection()
Sets the broker address and port number. |
Method Summary | |
---|---|
void |
cleanup()
Clean up. |
protected void |
close()
Close all connections to the JMS broker. |
java.lang.String |
getHost()
|
java.lang.String |
getPort()
|
protected abstract javax.jms.Queue |
getQueue(java.lang.String queueName)
Should be implemented according to a specific JMS broker. |
protected abstract javax.jms.QueueConnectionFactory |
getQueueConnectionFactory()
Should be implemented according to a specific JMS broker. |
protected abstract javax.jms.Topic |
getTopic(java.lang.String topicName)
Should be implemented according to a specific JMS broker. |
protected abstract javax.jms.TopicConnectionFactory |
getTopicConnectionFactory()
Should be implemented according to a specific JMS broker. |
protected void |
initConnection()
Initializes the JMS connection. |
java.util.List<javax.jms.Message> |
removeAllMessages(ChannelID mq)
Remove all messages waiting in a queue/topic. |
void |
removeListener(ChannelID mq,
javax.jms.MessageListener ml)
Removes the specified MessageListener from the given queue or topic. |
void |
reply(NetarkivetMessage nMsg)
Submit an object to the reply queue. |
void |
resend(NetarkivetMessage msg,
ChannelID to)
Sends a message msg to the channel defined by the parameter to - NOT the channel defined in the message. |
void |
send(NetarkivetMessage nMsg)
Submit an object to the destination queue. |
protected void |
sendMessage(NetarkivetMessage nMsg,
ChannelID to)
Submit an ObjectMessage to the destination channel. |
void |
setListener(ChannelID mq,
javax.jms.MessageListener ml)
Method adds a listener to the given queue or topic. |
static NetarkivetMessage |
unpack(javax.jms.Message msg)
Unwraps a NetarkivetMessage from an ObjectMessage. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
static final java.lang.String CONSUMER_KEY_SEPARATOR
Constructor Detail |
---|
protected JMSConnection()
Method Detail |
---|
protected void initConnection()
IOFailure
- if initialization fails.protected abstract javax.jms.QueueConnectionFactory getQueueConnectionFactory() throws javax.jms.JMSException
javax.jms.JMSException
protected abstract javax.jms.TopicConnectionFactory getTopicConnectionFactory() throws javax.jms.JMSException
javax.jms.JMSException
protected abstract javax.jms.Queue getQueue(java.lang.String queueName) throws javax.jms.JMSException
queueName
- the name of the wanted Queue
javax.jms.JMSException
protected abstract javax.jms.Topic getTopic(java.lang.String topicName) throws javax.jms.JMSException
topicName
- The name of the wanted Topic
javax.jms.JMSException
public final void send(NetarkivetMessage nMsg)
nMsg
- The NetarkivetMessage to send to the destination queue (null
not allowed)
ArgumentNotValid
- if nMsg is null.
IOFailure
- if the operation failed.public void reply(NetarkivetMessage nMsg)
nMsg
- The NetarkivetMessage to send to the reply queue (null not
allowed)
ArgumentNotValid
- if nMsg is null.
IOFailure
- if the operation failed.protected void sendMessage(NetarkivetMessage nMsg, ChannelID to) throws IOFailure
nMsg
- the NetarkivetMessage to be wrapped and send as an
ObjectMessageto
- the destination channel
IOFailure
- if message failed to be sent.public final void resend(NetarkivetMessage msg, ChannelID to)
msg
- Message to be sentto
- The destination channelprotected void close()
IOFailure
- if closing one of the internal connection objects failed.public void cleanup()
cleanup
in interface CleanupIF
public static NetarkivetMessage unpack(javax.jms.Message msg) throws ArgumentNotValid
msg
- a javax.jms.ObjectMessage
ArgumentNotValid
- when msg in valid or reply from JMS server is invalidpublic void setListener(ChannelID mq, javax.jms.MessageListener ml) throws IOFailure
mq
- the messagequeue to listen toml
- the messagelistener
IOFailure
- if the operation failed.public void removeListener(ChannelID mq, javax.jms.MessageListener ml) throws IOFailure
mq
- ml
-
IOFailure
public java.util.List<javax.jms.Message> removeAllMessages(ChannelID mq)
mq
- The queue/topic to remove messages from
public java.lang.String getHost()
public java.lang.String getPort()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |