public class MessagingMessageConverter extends java.lang.Object implements MessageConverter, InitializingBean
Message
from the messaging abstraction to and from a
javax.jms.Message
using an underlying MessageConverter
for the payload and a JmsHeaderMapper
to map the JMS headers to and from standard message headers.Modifier and Type | Field and Description |
---|---|
private JmsHeaderMapper |
headerMapper |
private MessageConverter |
payloadConverter |
Constructor and Description |
---|
MessagingMessageConverter()
Create an instance with a default 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 javax.jms.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(javax.jms.Message message) |
protected java.lang.Object |
extractPayload(javax.jms.Message message)
Extract the payload of the specified
javax.jms.Message . |
java.lang.Object |
fromMessage(javax.jms.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. |
javax.jms.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.
|
private MessageConverter payloadConverter
private JmsHeaderMapper headerMapper
public MessagingMessageConverter()
SimpleMessageConverter
,
SimpleJmsHeaderMapper
public 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 javax.jms.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 MessageMessageConversionException
- in case of conversion failureJMSException
public java.lang.Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException
MessageConverter
fromMessage
in interface MessageConverter
message
- the message to convertMessageConversionException
- in case of conversion failureJMSException
protected java.lang.Object extractPayload(javax.jms.Message message) throws JMSException
javax.jms.Message
.JMSException
protected javax.jms.Message createMessageForPayload(java.lang.Object payload, Session session, java.lang.Object conversionHint) throws JMSException
MessageConverter
,
e.g. the associated MethodParameter
(may be null
}.JMSException
MessageConverter.toMessage(Object, Session)
protected final MessageHeaders extractHeaders(javax.jms.Message message)