Spring Integration

org.springframework.integration.jms
Class DefaultMessageConverter

java.lang.Object
  extended by org.springframework.integration.jms.DefaultMessageConverter
All Implemented Interfaces:
MessageConverter

public class DefaultMessageConverter
extends Object
implements MessageConverter

A MessageConverter implementation that is capable of delegating to an existing converter instance. The default MessageConverter implementation is SimpleMessageConverter.

If 'extractJmsMessageBody' is true (the default), the body of each received JMS Message will be converted. Otherwise, the JMS Message itself will be returned.

If 'extractIntegrationMessagePayload' is true (the default), the payload of each outbound Spring Integration Message will be passed to the MessageConverter to produce the body of the JMS Message. Otherwise, the Spring Integration Message itself will become the body of the JMS Message.

Author:
Mark Fisher, Oleg Zhurakousky

Constructor Summary
DefaultMessageConverter()
          Create a DefaultMessageConverter instance that will rely on the default SimpleMessageConverter.
DefaultMessageConverter(MessageConverter converter)
          Create a DefaultMessageConverter instance that will delegate to the provided MessageConverter instance.
 
Method Summary
 Object fromMessage(javax.jms.Message jmsMessage)
          Converts from a JMS Message to an integration Message payload.
 void setExtractIntegrationMessagePayload(boolean extractIntegrationMessagePayload)
          Specify whether the outbound integration Message's payload should be extracted prior to conversion into a JMS Message.
 void setExtractJmsMessageBody(boolean extractJmsMessageBody)
          Specify whether the inbound JMS Message's body should be extracted during the conversion process.
 javax.jms.Message toMessage(Object object, javax.jms.Session session)
          Converts from an integration Message to a JMS Message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMessageConverter

public DefaultMessageConverter()
Create a DefaultMessageConverter instance that will rely on the default SimpleMessageConverter.


DefaultMessageConverter

public DefaultMessageConverter(MessageConverter converter)
Create a DefaultMessageConverter instance that will delegate to the provided MessageConverter instance.

Method Detail

setExtractJmsMessageBody

public void setExtractJmsMessageBody(boolean extractJmsMessageBody)
Specify whether the inbound JMS Message's body should be extracted during the conversion process. Otherwise, the raw JMS Message itself will be returned to be used as the payload.

The default value is true.


setExtractIntegrationMessagePayload

public void setExtractIntegrationMessagePayload(boolean extractIntegrationMessagePayload)
Specify whether the outbound integration Message's payload should be extracted prior to conversion into a JMS Message. Otherwise, the integration Message itself will be passed to the converter.

Typically, this setting should be determined by the expectations of the target system. If the target system is not capable of understanding a Spring Integration Message, then set this to true. On the other hand, if the system is not only capable of understanding a Spring Integration Message but actually expected to rely upon Spring Integration Message Header values, then this must be set to false to ensure that the actual Message will be passed along with its Serializable headers.

The default value is true.


fromMessage

public Object fromMessage(javax.jms.Message jmsMessage)
                   throws javax.jms.JMSException,
                          MessageConversionException
Converts from a JMS Message to an integration Message payload. If the 'extractJmsMessageBody' property is false, the JMS Message itself will be returned to be used as the payload.

Specified by:
fromMessage in interface MessageConverter
Throws:
javax.jms.JMSException
MessageConversionException

toMessage

public javax.jms.Message toMessage(Object object,
                                   javax.jms.Session session)
                            throws javax.jms.JMSException,
                                   MessageConversionException
Converts from an integration Message to a JMS Message.

Specified by:
toMessage in interface MessageConverter
Throws:
javax.jms.JMSException
MessageConversionException

Spring Integration

Copyright © 2010. All Rights Reserved.