org.objectweb.joram.mom.util

Class BridgeUnifiedModule

Implemented Interfaces:
javax.jms.ExceptionListener, javax.jms.MessageListener, java.io.Serializable
Known Direct Subclasses:
BridgePtpModule, BridgePubSubModule

public class BridgeUnifiedModule
extends java.lang.Object
implements javax.jms.ExceptionListener, javax.jms.MessageListener, java.io.Serializable

The BridgeUnifiedModule class is a bridge module based on the JMS 1.1 unified semantics and classes.

See Also:
Serialized Form

Nested Class Summary

protected class
BridgeUnifiedModule.ConsumerDaemon
The ConsumerDaemon thread allows to call MessageConsumer.receive() for requesting a foreign JMS message without blocking the JORAM server.
protected class
BridgeUnifiedModule.ReconnectionDaemon
The ReconnectionDaemon thread is responsible for reconnecting the bridge module with the foreign JMS server in case of disconnection.
protected class
BridgeUnifiedModule.StartupDaemon
The StartupDaemon thread is responsible for retrieving the needed JMS administered objects from the JNDI server.

Field Summary

protected AgentId
agentId
Identifier of the agent using this module.
protected String
clientID
JMS clientID field.
protected Connection
cnx
Connection to the foreign JMS server.
protected ConnectionFactory
cnxFact
Connection factory object for connecting to the foreign JMS server.
protected String
cnxFactName
ConnectionFactory JNDI name.
protected MessageConsumer
consumer
Consumer object.
protected BridgeUnifiedModule.ConsumerDaemon
consumerDaemon
Daemon used for requesting messages.
protected Session
consumerSession
Session for getting messages from the foreign JMS destination.
protected Destination
dest
Foreign JMS destination object.
protected String
destName
Destination JNDI name.
protected String
jndiFactory
Name of the JNDI factory class to use.
protected String
jndiUrl
JNDI URL.
protected boolean
listener
true if a listener has been set on the JMS consumer.
protected String
notUsableMessage
Message explaining why the module is not usable.
protected String
password
User password for connecting to the foreign JMS server.
protected MessageProducer
producer
Producer object.
protected Session
producerSession
Session for sending messages to the foreign JMS destination.
protected Vector
qout
Vector holding the pending messages to send after reconnection.
protected BridgeUnifiedModule.ReconnectionDaemon
reconnectionDaemon
Daemon used for the reconnection process.
protected String
selector
Selector for filtering messages.
protected boolean
usable
true if the module is fully usable.
protected String
userName
User identification for connecting to the foreign JMS server.

Constructor Summary

BridgeUnifiedModule()
Constructs a BridgeUnifiedModule module.

Method Summary

protected void
acknowledge(Message message)
Acknowledges a message successfuly delivered to the foreign JMS server.
void
close()
Interrupts the daemons and closes the connection.
void
connect()
Launches the connection process to the foreign JMS server.
protected void
doConnect()
Opens a connection with the foreign JMS server and creates the JMS resources for interacting with the foreign JMS destination.
void
init(AgentId agentId, Properties prop)
Initializes the module's parameters.
void
onException(JMSException exc)
Implements the javax.jms.ExceptionListener interface for catching the failures of the connection to the remote JMS server.
void
onMessage(javax.jms.Message jmsMessage)
Implements the javax.jms.MessageListener interface for processing the asynchronous deliveries coming from the foreign JMS server.
void
receive()
Asynchronous method requesting a delivery from the foreign JMS destination.
Message
receiveNoWait()
Synchronous method requesting an immediate delivery from the foreign JMS destination.
void
send(Message message)
Sends a message to the foreign JMS destination.
protected void
setConsumer()
Sets the JMS consumer on the foreign destination.
void
setMessageListener()
Sets a message listener on the foreign JMS destination.
protected void
unsetConsumer()
Unsets the JMS consumer.
void
unsetMessageListener()
Unsets the set message listener on the foreign JMS destination.

Field Details

agentId

protected AgentId agentId
Identifier of the agent using this module.


clientID

protected String clientID
JMS clientID field.


cnx

protected Connection cnx
Connection to the foreign JMS server.


cnxFact

protected ConnectionFactory cnxFact
Connection factory object for connecting to the foreign JMS server.


cnxFactName

protected String cnxFactName
ConnectionFactory JNDI name.


consumer

protected MessageConsumer consumer
Consumer object.


consumerDaemon

protected BridgeUnifiedModule.ConsumerDaemon consumerDaemon
Daemon used for requesting messages.


consumerSession

protected Session consumerSession
Session for getting messages from the foreign JMS destination.


dest

protected Destination dest
Foreign JMS destination object.


destName

protected String destName
Destination JNDI name.


jndiFactory

protected String jndiFactory
Name of the JNDI factory class to use.


jndiUrl

protected String jndiUrl
JNDI URL.


listener

protected boolean listener
true if a listener has been set on the JMS consumer.


notUsableMessage

protected String notUsableMessage
Message explaining why the module is not usable.


password

protected String password
User password for connecting to the foreign JMS server.


producer

protected MessageProducer producer
Producer object.


producerSession

protected Session producerSession
Session for sending messages to the foreign JMS destination.


qout

protected Vector qout
Vector holding the pending messages to send after reconnection.


reconnectionDaemon

protected BridgeUnifiedModule.ReconnectionDaemon reconnectionDaemon
Daemon used for the reconnection process.


selector

protected String selector
Selector for filtering messages.


usable

protected boolean usable
true if the module is fully usable.


userName

protected String userName
User identification for connecting to the foreign JMS server.

Constructor Details

BridgeUnifiedModule

public BridgeUnifiedModule()
Constructs a BridgeUnifiedModule module.

Method Details

acknowledge

protected void acknowledge(Message message)
Acknowledges a message successfuly delivered to the foreign JMS server.


close

public void close()
Interrupts the daemons and closes the connection.


connect

public void connect()
            throws JMSException
Launches the connection process to the foreign JMS server.


doConnect

protected void doConnect()
            throws JMSException
Opens a connection with the foreign JMS server and creates the JMS resources for interacting with the foreign JMS destination.


init

public void init(AgentId agentId,
                 Properties prop)
Initializes the module's parameters.

Parameters:
agentId - Identifier of the agent using the module.
prop - JMS properties required for establishing the link with the foreign JMS server.


onException

public void onException(JMSException exc)
Implements the javax.jms.ExceptionListener interface for catching the failures of the connection to the remote JMS server.

Reacts by launching a reconnection process.


onMessage

public void onMessage(javax.jms.Message jmsMessage)
Implements the javax.jms.MessageListener interface for processing the asynchronous deliveries coming from the foreign JMS server.


receive

public void receive()
            throws IllegalStateException
Asynchronous method requesting a delivery from the foreign JMS destination.


receiveNoWait

public Message receiveNoWait()
            throws IllegalStateException
Synchronous method requesting an immediate delivery from the foreign JMS destination.

Returns:
The JMS message formatted into a JORAM MOM message, or null if no message is available or if the request fails.


send

public void send(Message message)
            throws JMSException
Sends a message to the foreign JMS destination.


setConsumer

protected void setConsumer()
            throws JMSException
Sets the JMS consumer on the foreign destination.


setMessageListener

public void setMessageListener()
            throws IllegalStateException
Sets a message listener on the foreign JMS destination.


unsetConsumer

protected void unsetConsumer()
Unsets the JMS consumer.


unsetMessageListener

public void unsetMessageListener()
Unsets the set message listener on the foreign JMS destination.


Copyright B) 2004 Scalagent - All rights reserved