Class MessagingMessageConverter
- java.lang.Object
-
- org.springframework.amqp.support.converter.MessagingMessageConverter
-
- All Implemented Interfaces:
MessageConverter
,InitializingBean
- Direct Known Subclasses:
MessagingMessageListenerAdapter.MessagingMessageConverterAdapter
public class MessagingMessageConverter extends Object implements MessageConverter, InitializingBean
Convert aMessage
from the messaging abstraction to and from aMessage
using an underlyingMessageConverter
for the payload and aAmqpHeaderMapper
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
Constructors Constructor 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
protected Object
extractPayload(Message message)
Extract the payload of the specifiedMessage
.Object
fromMessage(Message message)
Convert from a Message to a Java object.AmqpHeaderMapper
getHeaderMapper()
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.Message
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 Detail
-
MessagingMessageConverter
public MessagingMessageConverter()
Create an instance with a default payload converter for an inbound handler.- See Also:
SimpleMessageConverter
,SimpleAmqpHeaderMapper
-
MessagingMessageConverter
public MessagingMessageConverter(MessageConverter payloadConverter, AmqpHeaderMapper headerMapper)
Create an instance with the specified payload converter and header mapper.- Parameters:
payloadConverter
- the targetMessageConverter
forpayload
.headerMapper
- theAmqpHeaderMapper
to map AMQP header toMessageHeaders
.
-
-
Method Detail
-
setPayloadConverter
public void setPayloadConverter(MessageConverter payloadConverter)
Set theMessageConverter
to use to convert the payload.- Parameters:
payloadConverter
- the targetMessageConverter
forpayload
.
-
setHeaderMapper
public void setHeaderMapper(AmqpHeaderMapper headerMapper)
Set theAmqpHeaderMapper
to use to map AMQP headers to and from standard message headers.- Parameters:
headerMapper
- theAmqpHeaderMapper
to map AMQP header toMessageHeaders
.
-
getHeaderMapper
public AmqpHeaderMapper 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
public Object fromMessage(Message message) throws MessageConversionException
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
-
-