public class SerializerMessageConverter extends WhiteListDeserializingMessageConverter
MessageConverter
that can work with Strings or native objects
of any kind via the Serializer
and Deserializer
abstractions in Spring.
The AbstractMessageConverter.toMessage(Object, MessageProperties)
method simply checks the type of the
provided instance while the fromMessage(Message)
method relies upon the
content-type
of the provided Message.
If a DefaultDeserializer
is configured (default),
the white list patterns
will be applied
(if configured); for all other deserializers, the deserializer is responsible for
checking classes, if necessary.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_CHARSET |
Constructor and Description |
---|
SerializerMessageConverter() |
Modifier and Type | Method and Description |
---|---|
protected Message |
createMessage(java.lang.Object object,
MessageProperties messageProperties)
Creates an AMQP Message from the provided Object.
|
java.lang.Object |
fromMessage(Message message)
Converts from a AMQP Message to an Object.
|
void |
setDefaultCharset(java.lang.String defaultCharset)
Specify the default charset to use when converting to or from text-based Message body content.
|
void |
setDeserializer(org.springframework.core.serializer.Deserializer<java.lang.Object> deserializer)
The deserializer to use for converting from message body to Java object.
|
void |
setIgnoreContentType(boolean ignoreContentType)
Flag to signal that the content type should be ignored and the deserializer used irrespective if it is a text
message.
|
void |
setSerializer(org.springframework.core.serializer.Serializer<java.lang.Object> serializer)
The serializer to use for converting Java objects to message bodies.
|
addWhiteListPatterns, checkWhiteList, setWhiteListPatterns
isCreateMessageIds, setCreateMessageIds, toMessage
public static final java.lang.String DEFAULT_CHARSET
public void setIgnoreContentType(boolean ignoreContentType)
ignoreContentType
- the flag value to setpublic void setDefaultCharset(java.lang.String defaultCharset)
defaultCharset
- The default charset.public void setSerializer(org.springframework.core.serializer.Serializer<java.lang.Object> serializer)
serializer
- the serializer to setpublic void setDeserializer(org.springframework.core.serializer.Deserializer<java.lang.Object> deserializer)
deserializer
- the deserializer to setpublic java.lang.Object fromMessage(Message message) throws MessageConversionException
fromMessage
in interface MessageConverter
fromMessage
in class AbstractMessageConverter
message
- the message to convertMessageConversionException
- in case of conversion failureprotected Message createMessage(java.lang.Object object, MessageProperties messageProperties) throws MessageConversionException
createMessage
in class AbstractMessageConverter
object
- the payloadmessageProperties
- the message properties (headers)MessageConversionException