org.springframework.integration.jms
Class HeaderMappingMessageConverter

java.lang.Object
  extended by org.springframework.integration.jms.HeaderMappingMessageConverter
All Implemented Interfaces:
org.springframework.jms.support.converter.MessageConverter

public class HeaderMappingMessageConverter
extends java.lang.Object
implements org.springframework.jms.support.converter.MessageConverter

A MessageConverter implementation that is capable of delegating to an existing converter instance and an existing JmsHeaderMapper. The default MessageConverter implementation is SimpleMessageConverter, and the default header mapper implementation is DefaultJmsHeaderMapper.

If 'extractJmsMessageBody' is true (the default), the body of each received JMS Message will become the payload of a Spring Integration Message. Otherwise, the JMS Message itself will be the payload of the Spring Integration Message.

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.

The JmsHeaderMapper will be applied regardless of the values specified for Message extraction.

Author:
Mark Fisher

Constructor Summary
HeaderMappingMessageConverter()
          Create a HeaderMappingMessageConverter instance that will rely on the default SimpleMessageConverter and DefaultJmsHeaderMapper.
HeaderMappingMessageConverter(JmsHeaderMapper headerMapper)
          Create a HeaderMappingMessageConverter instance that will delegate to the provided JmsHeaderMapper instance and will use the default SimpleMessageConverter implementation.
HeaderMappingMessageConverter(org.springframework.jms.support.converter.MessageConverter converter)
          Create a HeaderMappingMessageConverter instance that will delegate to the provided MessageConverter instance and will use the default implementation of the JmsHeaderMapper strategy.
HeaderMappingMessageConverter(org.springframework.jms.support.converter.MessageConverter converter, JmsHeaderMapper headerMapper)
          Create a HeaderMappingMessageConverter instance that will delegate to the provided MessageConverter and JmsHeaderMapper.
 
Method Summary
 java.lang.Object fromMessage(javax.jms.Message jmsMessage)
          Converts from a JMS Message to an integration Message.
 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(java.lang.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

HeaderMappingMessageConverter

public HeaderMappingMessageConverter()
Create a HeaderMappingMessageConverter instance that will rely on the default SimpleMessageConverter and DefaultJmsHeaderMapper.


HeaderMappingMessageConverter

public HeaderMappingMessageConverter(org.springframework.jms.support.converter.MessageConverter converter)
Create a HeaderMappingMessageConverter instance that will delegate to the provided MessageConverter instance and will use the default implementation of the JmsHeaderMapper strategy.


HeaderMappingMessageConverter

public HeaderMappingMessageConverter(JmsHeaderMapper headerMapper)
Create a HeaderMappingMessageConverter instance that will delegate to the provided JmsHeaderMapper instance and will use the default SimpleMessageConverter implementation.


HeaderMappingMessageConverter

public HeaderMappingMessageConverter(org.springframework.jms.support.converter.MessageConverter converter,
                                     JmsHeaderMapper headerMapper)
Create a HeaderMappingMessageConverter instance that will delegate to the provided MessageConverter and JmsHeaderMapper.

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 the payload of the created Spring Integration Message. The HeaderMapper will be applied to the Message regardless of this value.

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 java.lang.Object fromMessage(javax.jms.Message jmsMessage)
                             throws javax.jms.JMSException,
                                    org.springframework.jms.support.converter.MessageConversionException
Converts from a JMS Message to an integration Message.

Specified by:
fromMessage in interface org.springframework.jms.support.converter.MessageConverter
Throws:
javax.jms.JMSException
org.springframework.jms.support.converter.MessageConversionException

toMessage

public javax.jms.Message toMessage(java.lang.Object object,
                                   javax.jms.Session session)
                            throws javax.jms.JMSException,
                                   org.springframework.jms.support.converter.MessageConversionException
Converts from an integration Message to a JMS Message.

Specified by:
toMessage in interface org.springframework.jms.support.converter.MessageConverter
Throws:
javax.jms.JMSException
org.springframework.jms.support.converter.MessageConversionException