Class AbstractMessageConverter
java.lang.Object
org.springframework.amqp.support.converter.AbstractMessageConverter
- All Implemented Interfaces:
MessageConverter
- Direct Known Subclasses:
AbstractJackson2MessageConverter
,AllowedListDeserializingMessageConverter
,MarshallingMessageConverter
Convenient base class for
MessageConverter
implementations.- Author:
- Dave Syer, Gary Russell
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Message
createMessage
(Object object, MessageProperties messageProperties) Crate a message from the payload object and message properties provided.protected Message
createMessage
(Object object, MessageProperties messageProperties, Type genericType) Crate a message from the payload object and message properties provided.protected boolean
Flag to indicate that new messages should have unique identifiers added to their properties before sending.void
setCreateMessageIds
(boolean createMessageIds) Flag to indicate that new messages should have unique identifiers added to their properties before sending.final Message
toMessage
(Object object, MessageProperties messageProperties) Convert a Java object to a Message.final Message
toMessage
(Object object, MessageProperties messagePropertiesArg, Type genericType) 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
fromMessage
-
Constructor Details
-
AbstractMessageConverter
public AbstractMessageConverter()
-
-
Method Details
-
setCreateMessageIds
public void setCreateMessageIds(boolean createMessageIds) Flag to indicate that new messages should have unique identifiers added to their properties before sending. Default false.- Parameters:
createMessageIds
- the flag value to set
-
isCreateMessageIds
protected boolean isCreateMessageIds()Flag to indicate that new messages should have unique identifiers added to their properties before sending.- Returns:
- the flag value
-
toMessage
public final 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
-
toMessage
public final Message toMessage(Object object, @Nullable MessageProperties messagePropertiesArg, @Nullable Type genericType) throws MessageConversionException Description copied from interface:MessageConverter
Convert a Java object to a Message. The default implementation callsMessageConverter.toMessage(Object, MessageProperties)
.- Specified by:
toMessage
in interfaceMessageConverter
- Parameters:
object
- the object to convertmessagePropertiesArg
- The message properties.genericType
- the type to use to populate type headers.- Returns:
- the Message
- Throws:
MessageConversionException
- in case of conversion failure
-
createMessage
protected Message createMessage(Object object, MessageProperties messageProperties, @Nullable Type genericType) Crate a message from the payload object and message properties provided. The message id will be added to the properties if necessary later.- Parameters:
object
- the payloadmessageProperties
- the message properties (headers)genericType
- the type to convert from - used to populate type headers.- Returns:
- a message
- Since:
- 2.1
-
createMessage
Crate a message from the payload object and message properties provided. The message id will be added to the properties if necessary later.- Parameters:
object
- the payload.messageProperties
- the message properties (headers).- Returns:
- a message.
-