public class BridgeMDO extends MessengerMDO
BridgeMDO
is an MDO which implements a JMS bridge
from one JMS destination and connection to another.
This allows messages to be consumed on one destination and sent to
another JMS destination, using possibly different JMS providers.
For example this can be used to bridge from SpiritWave to MQSeries.
This class is a useful base class to other possible bridge implementations such as 2 phase commit bridges or bridges with some complex transformation etc. This class has a number of Factory and Strategy methods to further customize the acknowledgement and transaction management, the message construction, transformation and how to handle message headers etc.
Modifier and Type | Field and Description |
---|---|
private int |
bufferSize
the buffer size used for ByteMessage and StreamMessage copying
|
private static org.apache.commons.logging.Log |
log
Logger
|
private java.lang.String |
outputConnection
the name of the messenger to use for output
|
private javax.jms.Destination |
outputDestination
the Destination output messages will be sent to
|
private Messenger |
outputMessenger
the Messenger used to output messages
|
private java.lang.String |
outputSubject
the name of the destination to use
|
private boolean |
transacted
should this MDO work in transacted mode
|
Constructor and Description |
---|
BridgeMDO() |
Modifier and Type | Method and Description |
---|---|
protected void |
acknowledge(javax.jms.Message message)
Strategy method to allow different derived classes to acknowledge
messages differently, such as to disable acknowledgements
|
protected void |
commit()
Strategy method to perform a commit() on both the incoming Messenger and the
output Messenger.
|
protected javax.jms.BytesMessage |
createOutputBytesMessage(javax.jms.BytesMessage inputMessage)
Factory method to create BytesMessage
Derived classes could override this method to perform any kind of
Message transformation.
|
protected javax.jms.MapMessage |
createOutputMapMessage(javax.jms.MapMessage inputMessage)
Factory method to create MapMessage
Derived classes could override this method to perform any kind of
Message transformation.
|
protected javax.jms.Message |
createOutputMessage(javax.jms.Message inputMessage)
Factory method to create an output message given an input message.
|
protected javax.jms.ObjectMessage |
createOutputObjectMessage(javax.jms.ObjectMessage inputMessage)
Factory method to create ObjectMessage
Derived classes could override this method to perform any kind of
Message transformation.
|
protected javax.jms.StreamMessage |
createOutputStreamMessage(javax.jms.StreamMessage inputMessage)
Factory method to create StreamMessage
Derived classes could override this method to perform any kind of
Message transformation.
|
protected javax.jms.TextMessage |
createOutputTextMessage(javax.jms.TextMessage inputMessage)
Factory method to create TextMessage
Derived classes could override this method to perform any kind of
Message transformation.
|
int |
getBufferSize()
Gets the buffer size used for ByteMessage and StreamMessage copying
|
java.lang.String |
getOutputConnection() |
javax.jms.Destination |
getOutputDestination()
Gets the Destination output messages will be sent to
|
Messenger |
getOutputMessenger()
Gets the Messenger used to output messages
|
java.lang.String |
getOutputSubject() |
void |
init()
This method allows the init() method to be overriden without having to
call the super.init( ServletContext ) method first.
|
boolean |
isTransacted() |
void |
onMessage(javax.jms.Message message) |
protected void |
processMessageHeaders(javax.jms.Message inputMessage,
javax.jms.Message outputMessage)
Strategy method to add any headers required on the output message.
|
protected void |
rollback()
Strategy method to perform a rollback() on both the incoming Messenger and the
output Messenger.
|
void |
setBufferSize(int bufferSize)
Sets the buffer size used for ByteMessage and StreamMessage copying
|
void |
setOutputConnection(java.lang.String outputConnection)
Sets the connection name (messenger instance) to use
to output messages
|
void |
setOutputDestination(javax.jms.Destination outputDestination)
Sets the Destination output messages will be sent to
|
void |
setOutputMessenger(Messenger outputMessenger)
Sets the Messenger used to output messages
|
void |
setOutputSubject(java.lang.String outputSubject)
Sets the subject (i.e.
|
void |
setTransacted(boolean transacted)
Sets whether this MDO should work in transacted mode
|
protected void |
validateOutputDestination()
Validates that there is a valid output destintation that we can use.
|
getMessenger, getMessengerManager, setMessenger, setMessengerManager
destroy, getLog, getServletContext, init, log, log
private static final org.apache.commons.logging.Log log
private Messenger outputMessenger
private javax.jms.Destination outputDestination
private java.lang.String outputConnection
private java.lang.String outputSubject
private int bufferSize
private boolean transacted
public void init() throws javax.servlet.ServletException
MessageDrivenObjectSupport
GenericServlet
.init
in class MessageDrivenObjectSupport
javax.servlet.ServletException
public void onMessage(javax.jms.Message message)
public boolean isTransacted()
public void setTransacted(boolean transacted)
public java.lang.String getOutputConnection()
public void setOutputConnection(java.lang.String outputConnection)
public java.lang.String getOutputSubject()
public void setOutputSubject(java.lang.String outputSubject)
public Messenger getOutputMessenger() throws javax.jms.JMSException
javax.jms.JMSException
public void setOutputMessenger(Messenger outputMessenger)
public javax.jms.Destination getOutputDestination() throws javax.jms.JMSException
javax.jms.JMSException
public void setOutputDestination(javax.jms.Destination outputDestination)
public int getBufferSize()
public void setBufferSize(int bufferSize)
protected void commit() throws javax.jms.JMSException
javax.jms.JMSException
protected void rollback()
protected javax.jms.Message createOutputMessage(javax.jms.Message inputMessage) throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.ObjectMessage createOutputObjectMessage(javax.jms.ObjectMessage inputMessage) throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.TextMessage createOutputTextMessage(javax.jms.TextMessage inputMessage) throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.MapMessage createOutputMapMessage(javax.jms.MapMessage inputMessage) throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.BytesMessage createOutputBytesMessage(javax.jms.BytesMessage inputMessage) throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.StreamMessage createOutputStreamMessage(javax.jms.StreamMessage inputMessage) throws javax.jms.JMSException
javax.jms.JMSException
protected void processMessageHeaders(javax.jms.Message inputMessage, javax.jms.Message outputMessage) throws javax.jms.JMSException
javax.jms.JMSException
protected void acknowledge(javax.jms.Message message) throws javax.jms.JMSException
javax.jms.JMSException
protected void validateOutputDestination() throws javax.jms.JMSException, javax.servlet.ServletException
javax.jms.JMSException
javax.servlet.ServletException