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 aMessage
from the messaging abstraction to and from aMessage
using an underlyingMessageConverter
for the payload and aJmsHeaderMapper
to map the JMS headers to and from standard message headers.- Since:
- 4.1
- Author:
- Stephane Nicoll
Constructor Summary
Constructors Constructor Description MessagingMessageConverter()
Create an instance with a default payload converter.MessagingMessageConverter(MessageConverter payloadConverter)
Create an instance with the specific payload converter.MessagingMessageConverter(MessageConverter payloadConverter, JmsHeaderMapper headerMapper)
Create an instance with the specified payload converter and header mapper.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.protected Message
createMessageForPayload(Object payload, Session session)
Deprecated.as of 4.3, usecreateMessageForPayload(Object, Session, Object)
protected Message
createMessageForPayload(Object payload, Session session, Object conversionHint)
Create a JMS message for the specified payload and conversionHint.protected MessageHeaders
extractHeaders(Message message)
protected Object
extractPayload(Message message)
Extract the payload of the specifiedMessage
.Object
fromMessage(Message message)
Convert from a JMS Message to a Java object.void
setHeaderMapper(JmsHeaderMapper headerMapper)
Set theJmsHeaderMapper
to use to map JMS headers to and from standard message headers.void
setPayloadConverter(MessageConverter payloadConverter)
Set theMessageConverter
to use to convert the payload.Message
toMessage(Object object, Session session)
Convert a Java object to a JMS Message using the supplied session to create the message object.
Constructor Detail
MessagingMessageConverter
public MessagingMessageConverter()
Create an instance with a default payload converter.- See Also:
SimpleMessageConverter
,SimpleJmsHeaderMapper
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 Detail
setPayloadConverter
public void setPayloadConverter(MessageConverter payloadConverter)
Set theMessageConverter
to use to convert the payload.
setHeaderMapper
public void setHeaderMapper(JmsHeaderMapper headerMapper)
Set theJmsHeaderMapper
to use to map JMS headers to and from standard message headers.
afterPropertiesSet
public void afterPropertiesSet()
Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,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 interfaceInitializingBean
toMessage
public Message toMessage(Object object, Session session) throws 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 interfaceMessageConverter
- Parameters:
object
- the object to convertsession
- the Session to use for creating a JMS Message- Returns:
- the JMS Message
- Throws:
JMSException
- if thrown by JMS API methodsMessageConversionException
- in case of conversion failure
fromMessage
public Object fromMessage(Message message) throws JMSException, MessageConversionException
Description copied from interface:MessageConverter
Convert from a JMS Message to a Java object.- Specified by:
fromMessage
in interfaceMessageConverter
- Parameters:
message
- the message to convert- Returns:
- the converted Java object
- Throws:
JMSException
- if thrown by JMS API methodsMessageConversionException
- in case of conversion failure
extractPayload
protected Object extractPayload(Message message) throws JMSException
Extract the payload of the specifiedMessage
.- Throws:
JMSException
createMessageForPayload
@Deprecated protected Message createMessageForPayload(Object payload, Session session) throws JMSException
Deprecated.as of 4.3, usecreateMessageForPayload(Object, Session, Object)
Create a JMS message for the specified payload.- Throws:
JMSException
- See Also:
MessageConverter.toMessage(Object, Session)
createMessageForPayload
protected Message createMessageForPayload(Object payload, Session session, Object conversionHint) throws JMSException
Create a JMS message for the specified payload and conversionHint. The conversion hint is an extra object passed to theMessageConverter
, e.g. the associatedMethodParameter
(may benull
}.- Throws:
JMSException
- Since:
- 4.3
- See Also:
MessageConverter.toMessage(Object, Session)
extractHeaders
protected final MessageHeaders extractHeaders(Message message)