Class MessagingMessageConverter
java.lang.Object
org.springframework.amqp.support.converter.MessagingMessageConverter
- All Implemented Interfaces:
MessageConverter
,InitializingBean
- Direct Known Subclasses:
MessagingMessageListenerAdapter.MessagingMessageConverterAdapter
Convert a
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).
- Since:
- 1.4
- Author:
- Stephane Nicoll
-
Constructor Summary
ConstructorDescriptionCreate 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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected Object
extractPayload
(Message message) Extract the payload of the specifiedMessage
.fromMessage
(Message message) Convert from a Message to a Java object.void
setHeaderMapper
(AmqpHeaderMapper headerMapper) Set theAmqpHeaderMapper
to use to map AMQP headers to and from standard message headers.void
setPayloadConverter
(MessageConverter payloadConverter) Set theMessageConverter
to use to convert the payload.toMessage
(Object object, MessageProperties messageProperties) Convert a Java object to a Message.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.amqp.support.converter.MessageConverter
toMessage
-
Constructor Details
-
MessagingMessageConverter
public MessagingMessageConverter()Create an instance with a default payload converter for an inbound handler.- See Also:
-
MessagingMessageConverter
Create an instance with the specified payload converter and header mapper.- Parameters:
payloadConverter
- the targetMessageConverter
forpayload
.headerMapper
- theAmqpHeaderMapper
to map AMQP header toMessageHeaders
.
-
-
Method Details
-
setPayloadConverter
Set theMessageConverter
to use to convert the payload.- Parameters:
payloadConverter
- the targetMessageConverter
forpayload
.
-
setHeaderMapper
Set theAmqpHeaderMapper
to use to map AMQP headers to and from standard message headers.- Parameters:
headerMapper
- theAmqpHeaderMapper
to map AMQP header toMessageHeaders
.
-
getHeaderMapper
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSet
in interfaceInitializingBean
-
toMessage
public Message toMessage(Object object, MessageProperties messageProperties) throws MessageConversionException Description copied from interface:MessageConverter
Convert a Java object to a Message.- Specified by:
toMessage
in interfaceMessageConverter
- Parameters:
object
- the object to convertmessageProperties
- The message properties.- Returns:
- the Message
- Throws:
MessageConversionException
- in case of conversion failure
-
fromMessage
Description copied from interface:MessageConverter
Convert from a Message to a Java object.- Specified by:
fromMessage
in interfaceMessageConverter
- Parameters:
message
- the message to convert- Returns:
- the converted Java object
- Throws:
MessageConversionException
- in case of conversion failure
-
extractPayload
Extract the payload of the specifiedMessage
.- Parameters:
message
- the AMQP Message to extractpayload
.- Returns:
- the extracted
payload
.
-