Class MessagingMessageConverter

java.lang.Object
org.springframework.jms.support.converter.MessagingMessageConverter
All Implemented Interfaces:
InitializingBean, MessageConverter

public class MessagingMessageConverter extends Object implements MessageConverter, InitializingBean
Convert a Message from the messaging abstraction to and from a Message using an underlying MessageConverter for the payload and a JmsHeaderMapper to map the JMS headers to and from standard message headers.
Since:
4.1
Author:
Stephane Nicoll
  • Constructor Details

    • MessagingMessageConverter

      public MessagingMessageConverter()
      Create an instance with a default payload converter.
      See Also:
    • MessagingMessageConverter

      public MessagingMessageConverter(MessageConverter payloadConverter)
      Create an instance with the specific payload converter.
      Parameters:
      payloadConverter - the payload converter to use
      Since:
      4.3.12
    • MessagingMessageConverter

      public MessagingMessageConverter(MessageConverter payloadConverter, JmsHeaderMapper headerMapper)
      Create an instance with the specified payload converter and header mapper.
  • Method Details

    • setPayloadConverter

      public void setPayloadConverter(MessageConverter payloadConverter)
      Set the MessageConverter to use to convert the payload.
    • setHeaderMapper

      public void setHeaderMapper(JmsHeaderMapper headerMapper)
      Set the JmsHeaderMapper to use to map JMS headers to and from standard message headers.
    • afterPropertiesSet

      public void afterPropertiesSet()
      Description copied from interface: InitializingBean
      Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

      This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

      Specified by:
      afterPropertiesSet in interface InitializingBean
    • toMessage

      public jakarta.jms.Message toMessage(Object object, jakarta.jms.Session session) throws jakarta.jms.JMSException, MessageConversionException
      Description copied from interface: MessageConverter
      Convert a Java object to a JMS Message using the supplied session to create the message object.
      Specified by:
      toMessage in interface MessageConverter
      Parameters:
      object - the object to convert
      session - the Session to use for creating a JMS Message
      Returns:
      the JMS Message
      Throws:
      jakarta.jms.JMSException - if thrown by JMS API methods
      MessageConversionException - in case of conversion failure
    • fromMessage

      public Object fromMessage(jakarta.jms.Message message) throws jakarta.jms.JMSException, MessageConversionException
      Description copied from interface: MessageConverter
      Convert from a JMS Message to a Java object.
      Specified by:
      fromMessage in interface MessageConverter
      Parameters:
      message - the message to convert
      Returns:
      the converted Java object
      Throws:
      jakarta.jms.JMSException - if thrown by JMS API methods
      MessageConversionException - in case of conversion failure
    • extractPayload

      protected Object extractPayload(jakarta.jms.Message message) throws jakarta.jms.JMSException
      Extract the payload of the specified Message.
      Throws:
      jakarta.jms.JMSException
    • createMessageForPayload

      protected jakarta.jms.Message createMessageForPayload(Object payload, jakarta.jms.Session session, @Nullable Object conversionHint) throws jakarta.jms.JMSException
      Create a JMS message for the specified payload and conversionHint. The conversion hint is an extra object passed to the MessageConverter, for example, the associated MethodParameter (may be null).
      Throws:
      jakarta.jms.JMSException
      Since:
      4.3
      See Also:
    • extractHeaders

      protected final MessageHeaders extractHeaders(jakarta.jms.Message message)