public class MessagingMessageConverter extends java.lang.Object implements MessageConverter, org.springframework.beans.factory.InitializingBean
Message
from the messaging abstraction to and from a
Message
using an underlying
MessageConverter
for the payload and a
AmqpHeaderMapper
to map the
AMQP headers to and from standard message headers.
The inbound flag determines how headers should be mapped. If true
(default), the caller is an inbound listener (i.e. parsing an AMQP message
is considered to be a request).
Constructor and Description |
---|
MessagingMessageConverter()
Create an instance with a default payload converter for an inbound
handler.
|
MessagingMessageConverter(MessageConverter payloadConverter,
AmqpHeaderMapper headerMapper)
Create an instance with the specified payload converter and
header mapper.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
protected java.lang.Object |
extractPayload(Message message)
Extract the payload of the specified
Message . |
java.lang.Object |
fromMessage(Message message)
Convert from a Message to a Java object.
|
void |
setHeaderMapper(AmqpHeaderMapper headerMapper)
Set the
AmqpHeaderMapper to use to map AMQP 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,
MessageProperties messageProperties)
Convert a Java object to a Message.
|
public MessagingMessageConverter()
SimpleMessageConverter
,
SimpleAmqpHeaderMapper
public MessagingMessageConverter(MessageConverter payloadConverter, AmqpHeaderMapper headerMapper)
payloadConverter
- the target MessageConverter
for payload
.headerMapper
- the AmqpHeaderMapper
to map AMQP header to MessageHeaders
.public void setPayloadConverter(MessageConverter payloadConverter)
MessageConverter
to use to convert the payload.payloadConverter
- the target MessageConverter
for payload
.public void setHeaderMapper(AmqpHeaderMapper headerMapper)
AmqpHeaderMapper
to use to map AMQP headers to and from
standard message headers.headerMapper
- the AmqpHeaderMapper
to map AMQP header to MessageHeaders
.public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public Message toMessage(java.lang.Object object, MessageProperties messageProperties) throws MessageConversionException
MessageConverter
toMessage
in interface MessageConverter
object
- the object to convertmessageProperties
- The message properties.MessageConversionException
- in case of conversion failurepublic java.lang.Object fromMessage(Message message) throws MessageConversionException
MessageConverter
fromMessage
in interface MessageConverter
message
- the message to convertMessageConversionException
- in case of conversion failure