com.atomikos.jms
Class AbstractBridge

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

public abstract class AbstractBridge
extends Object
implements MessageListener

Copyright © 2004, Atomikos. All rights reserved. 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  Message bridgeMessage(Message message)
          Transform a message into another message.
protected  void copyHeadersAndProperties(Message fromMessage, Message toMessage)
          Utility method to copy the headers from one message to another.
protected  BytesMessage createBytesMessage()
          Create a new bytes message.
protected  MapMessage createMapMessage()
          Create a new map message.
protected  ObjectMessage createObjectMessage()
          Create a new object message.
protected  StreamMessage createStreamMessage()
          Create a new stream message.
protected  TextMessage createTextMessage()
          Create a new text message.
 void onMessage(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 TextMessage createTextMessage()
                                 throws JMSException
Create a new text message. Subclasses can use this method to create a text message for the destination.

Returns:
Throws:
JMSException

createBytesMessage

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

Returns:
Throws:
JMSException

createStreamMessage

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

Returns:
Throws:
JMSException

createObjectMessage

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

Returns:
Throws:
JMSException

createMapMessage

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

Returns:
Throws:
JMSException

copyHeadersAndProperties

protected void copyHeadersAndProperties(Message fromMessage,
                                        Message toMessage)
                                 throws 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:
JMSException

bridgeMessage

protected abstract Message bridgeMessage(Message message)
                                  throws 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:
JMSException

onMessage

public final void onMessage(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 MessageListener