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
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 Object |
extractPayload(Message message)
Extract the payload of the specified
Message . |
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(Object object,
MessageProperties messageProperties)
Convert a Java object to a Message.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toMessage
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 InitializingBean
public Message toMessage(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 Object fromMessage(Message message) throws MessageConversionException
MessageConverter
fromMessage
in interface MessageConverter
message
- the message to convertMessageConversionException
- in case of conversion failure