public class MessagingMessageConverter extends Object implements MessageConverter, InitializingBean
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.Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
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 specified
Message . |
Object |
fromMessage(Message message)
Convert from a JMS Message to a Java object.
|
void |
setHeaderMapper(JmsHeaderMapper headerMapper)
Set the
JmsHeaderMapper to use to map JMS headers to and from
standard message headers. |
void |
setPayloadConverter(MessageConverter payloadConverter)
Set the
MessageConverter 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.
|
public MessagingMessageConverter()
SimpleMessageConverter
,
SimpleJmsHeaderMapper
public MessagingMessageConverter(MessageConverter payloadConverter)
payloadConverter
- the payload converter to usepublic MessagingMessageConverter(MessageConverter payloadConverter, JmsHeaderMapper headerMapper)
public void setPayloadConverter(MessageConverter payloadConverter)
MessageConverter
to use to convert the payload.public void setHeaderMapper(JmsHeaderMapper headerMapper)
JmsHeaderMapper
to use to map JMS headers to and from
standard message headers.public void afterPropertiesSet()
InitializingBean
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.
afterPropertiesSet
in interface InitializingBean
public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException
MessageConverter
toMessage
in interface MessageConverter
object
- the object to convertsession
- the Session to use for creating a JMS MessageJMSException
- if thrown by JMS API methodsMessageConversionException
- in case of conversion failurepublic Object fromMessage(Message message) throws JMSException, MessageConversionException
MessageConverter
fromMessage
in interface MessageConverter
message
- the message to convertJMSException
- if thrown by JMS API methodsMessageConversionException
- in case of conversion failureprotected Object extractPayload(Message message) throws JMSException
Message
.JMSException
protected Message createMessageForPayload(Object payload, Session session, @Nullable Object conversionHint) throws JMSException
MessageConverter
,
e.g. the associated MethodParameter
(may be null
}.JMSException
MessageConverter.toMessage(Object, Session)
protected final MessageHeaders extractHeaders(Message message)