public class Jackson2JsonMessageConverter extends AbstractJsonMessageConverter
DEFAULT_CHARSET
Constructor and Description |
---|
Jackson2JsonMessageConverter()
Construct with an internal
ObjectMapper instance. |
Jackson2JsonMessageConverter(com.fasterxml.jackson.databind.ObjectMapper jsonObjectMapper)
Construct with the provided
ObjectMapper instance. |
Modifier and Type | Method and Description |
---|---|
protected Message |
createMessage(Object objectToConvert,
MessageProperties messageProperties)
Crate a message from the payload object and message properties provided.
|
Object |
fromMessage(Message message)
Convert from a Message to a Java object.
|
Jackson2JavaTypeMapper |
getJavaTypeMapper() |
Jackson2JavaTypeMapper.TypePrecedence |
getTypePrecedence() |
protected void |
initializeJsonObjectMapper()
Deprecated.
in favor of
Jackson2JsonMessageConverter(ObjectMapper) constructor
with externally configured ObjectMapper . |
void |
setBeanClassLoader(ClassLoader classLoader) |
void |
setJavaTypeMapper(Jackson2JavaTypeMapper javaTypeMapper) |
void |
setJsonObjectMapper(com.fasterxml.jackson.databind.ObjectMapper jsonObjectMapper)
Deprecated.
in favor of
Jackson2JsonMessageConverter(ObjectMapper) constructor |
void |
setTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence typePrecedence)
Set the precedence for evaluating type information in message properties.
|
getClassLoader, getClassMapper, getDefaultCharset, setClassMapper, setDefaultCharset
isCreateMessageIds, setCreateMessageIds, toMessage
public Jackson2JsonMessageConverter()
ObjectMapper
instance.
The DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
is set to false on
the ObjectMapper
.public Jackson2JsonMessageConverter(com.fasterxml.jackson.databind.ObjectMapper jsonObjectMapper)
ObjectMapper
instance.jsonObjectMapper
- the ObjectMapper
to use.public Jackson2JavaTypeMapper getJavaTypeMapper()
public void setJavaTypeMapper(Jackson2JavaTypeMapper javaTypeMapper)
@Deprecated public void setJsonObjectMapper(com.fasterxml.jackson.databind.ObjectMapper jsonObjectMapper)
Jackson2JsonMessageConverter(ObjectMapper)
constructorObjectMapper
to use instead of using the default.jsonObjectMapper
- the object mapper to setpublic Jackson2JavaTypeMapper.TypePrecedence getTypePrecedence()
setTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence)
public void setTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence typePrecedence)
@RabbitListener
at the method level, the framework attempts
to determine the target type for payload conversion from the method signature.
If so, this type is provided in the
inferredArgumentType
message property.
By default, if the type is concrete (not abstract, not an interface), this will
be used ahead of type information provided in the __TypeId__
and
associated headers provided by the sender.
If you wish to force the use of the __TypeId__
and associated headers
(such as when the actual type is a subclass of the method argument type),
set the precedence to Jackson2JavaTypeMapper.TypePrecedence.TYPE_ID
.
typePrecedence
- the precedence.DefaultJackson2JavaTypeMapper.setTypePrecedence(Jackson2JavaTypeMapper.TypePrecedence)
public void setBeanClassLoader(ClassLoader classLoader)
setBeanClassLoader
in interface BeanClassLoaderAware
setBeanClassLoader
in class AbstractJsonMessageConverter
@Deprecated protected void initializeJsonObjectMapper()
Jackson2JsonMessageConverter(ObjectMapper)
constructor
with externally configured ObjectMapper
.ObjectMapper
instance.public Object fromMessage(Message message) throws MessageConversionException
MessageConverter
fromMessage
in interface MessageConverter
fromMessage
in class AbstractMessageConverter
message
- the message to convertMessageConversionException
- in case of conversion failureprotected Message createMessage(Object objectToConvert, MessageProperties messageProperties) throws MessageConversionException
AbstractMessageConverter
createMessage
in class AbstractMessageConverter
objectToConvert
- the payloadmessageProperties
- the message properties (headers)MessageConversionException