public class MessagingMessageConverter extends java.lang.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 a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
protected Message |
createMessageForPayload(java.lang.Object payload,
Session session,
java.lang.Object conversionHint)
Create a JMS message for the specified payload and conversionHint.
|
protected MessageHeaders |
extractHeaders(Message message) |
protected java.lang.Object |
extractPayload(Message message)
Extract the payload of the specified
Message . |
java.lang.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(java.lang.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
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
public Message toMessage(java.lang.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 java.lang.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 java.lang.Object extractPayload(Message message) throws JMSException
Message
.JMSException
protected Message createMessageForPayload(java.lang.Object payload, Session session, @Nullable java.lang.Object conversionHint) throws JMSException
MessageConverter
,
e.g. the associated MethodParameter
(may be null
}.JMSException
MessageConverter.toMessage(Object, Session)
protected final MessageHeaders extractHeaders(Message message)