com.atomikos.jms
Class AbstractBridge

java.lang.Object
  extended by com.atomikos.jms.AbstractBridge
All Implemented Interfaces:
javax.jms.MessageListener
Direct Known Subclasses:
Bridge

public abstract class AbstractBridge
extends Object
implements javax.jms.MessageListener

An abstract superclass for transactional destination bridging between a receiver and a sender destination. The destination is set explicitly as a MessageProducerSessionFactory, whereas the source is set implicitly by setting a bridge instance as the MessageListener to a Queue(Topic)ReceiverSession or Queue(Topic)ReceiverSessionPool. Subclasses should implement the bridgeMessage method to convert the JMS message format from the source session to the destination.


Constructor Summary
protected AbstractBridge()
           
 
Method Summary
protected abstract  javax.jms.Message bridgeMessage(javax.jms.Message message)
          Transform a message into another message.
protected  void copyHeadersAndProperties(javax.jms.Message fromMessage, javax.jms.Message toMessage)
          Utility method to copy the headers from one message to another.
protected  javax.jms.BytesMessage createBytesMessage()
          Create a new bytes message.
protected  javax.jms.MapMessage createMapMessage()
          Create a new map message.
protected  javax.jms.ObjectMessage createObjectMessage()
          Create a new object message.
protected  javax.jms.StreamMessage createStreamMessage()
          Create a new stream message.
protected  javax.jms.TextMessage createTextMessage()
          Create a new text message.
 void onMessage(javax.jms.Message message)
          This method is called by the source session when there is an incoming message.
 void setDestinationSessionFactory(MessageProducerSessionFactory destinationFactory)
          Set the destination session factory; this is a sender session factory that connects to the destination in the destination domain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBridge

protected AbstractBridge()
Method Detail

setDestinationSessionFactory

public void setDestinationSessionFactory(MessageProducerSessionFactory destinationFactory)
Set the destination session factory; this is a sender session factory that connects to the destination in the destination domain.

Parameters:
destinationFactory -

createTextMessage

protected javax.jms.TextMessage createTextMessage()
                                           throws javax.jms.JMSException
Create a new text message. Subclasses can use this method to create a text message for the destination.

Returns:
Throws:
javax.jms.JMSException

createBytesMessage

protected javax.jms.BytesMessage createBytesMessage()
                                             throws javax.jms.JMSException
Create a new bytes message. Subclasses can use this method to create a bytes message for the destination.

Returns:
Throws:
javax.jms.JMSException

createStreamMessage

protected javax.jms.StreamMessage createStreamMessage()
                                               throws javax.jms.JMSException
Create a new stream message. Subclasses can use this method to create a stream message for the destination.

Returns:
Throws:
javax.jms.JMSException

createObjectMessage

protected javax.jms.ObjectMessage createObjectMessage()
                                               throws javax.jms.JMSException
Create a new object message. Subclasses can use this method to create an object message for the destination.

Returns:
Throws:
javax.jms.JMSException

createMapMessage

protected javax.jms.MapMessage createMapMessage()
                                         throws javax.jms.JMSException
Create a new map message. Subclasses can use this method to create a map message for the destination.

Returns:
Throws:
javax.jms.JMSException

copyHeadersAndProperties

protected void copyHeadersAndProperties(javax.jms.Message fromMessage,
                                        javax.jms.Message toMessage)
                                 throws javax.jms.JMSException
Utility method to copy the headers from one message to another. Subclasses can use this method to easily copy the message headers and properties for bridged messages.

Parameters:
fromMessage - The incoming message
toMessage - The bridged message as constructed by the subclass.
Throws:
javax.jms.JMSException

bridgeMessage

protected abstract javax.jms.Message bridgeMessage(javax.jms.Message message)
                                            throws javax.jms.JMSException
Transform a message into another message. Subclasses should override this method to change the argument message format into the returned message format.

Parameters:
message - The message as it comes from the source session (and queue).
Returns:
Message The corresponding message to be put on the destination queue.
Throws:
javax.jms.JMSException

onMessage

public final void onMessage(javax.jms.Message message)
This method is called by the source session when there is an incoming message. The implementation delegates to transformMessage to obtain a converted message that it then sends on to the destination.

Specified by:
onMessage in interface javax.jms.MessageListener


Copyright © 2011. All Rights Reserved.