Class AbstractMessagingMessageConverter<S>
java.lang.Object
io.awspring.cloud.sqs.support.converter.AbstractMessagingMessageConverter<S>
- All Implemented Interfaces:
ContextAwareMessagingMessageConverter<S>
,MessagingMessageConverter<S>
- Direct Known Subclasses:
SqsMessagingMessageConverter
public abstract class AbstractMessagingMessageConverter<S>
extends Object
implements ContextAwareMessagingMessageConverter<S>
Base
MessagingMessageConverter
implementation.- Since:
- 3.0
- Author:
- Tomaz Fernandes
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract HeaderMapper<S>
An optional context to be used in the conversion process.protected abstract S
doConvertMessage
(S messageWithHeaders, Object payload) void
Configure the converter to not include payload type information in theMessage
headers.fromMessagingMessage
(Message<?> message, MessageConversionContext context) Convert aMessage
to a message from a specific messaging system.Get theMessageConverter
to be used for converting theMessage
instances payloads.protected abstract Object
getPayloadToDeserialize
(S message) void
setHeaderMapper
(HeaderMapper<S> headerMapper) Set theHeaderMapper
to used to convert headers forMessage
instances.void
setObjectMapper
(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Set theObjectMapper
instance to be used for converting theMessage
instances payloads.void
setPayloadMessageConverter
(MessageConverter messageConverter) Set theMessageConverter
to be used for converting theMessage
instances payloads.void
setPayloadTypeHeader
(String typeHeader) Set the name of the header to be looked up in aMessage
instance by thedefaultHeaderTypeMapping(Message)
.void
setPayloadTypeHeaderValueFunction
(Function<Message<?>, String> payloadTypeHeaderFunction) Set the function to create the payload type header value from.void
setPayloadTypeMapper
(Function<Message<?>, Class<?>> payloadTypeMapper) Set the payload type mapper to be used by this converter.Message<?>
toMessagingMessage
(S message, MessageConversionContext context) Convert a source message from a specific messaging system to aMessage
with an optional context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.awspring.cloud.sqs.support.converter.ContextAwareMessagingMessageConverter
fromMessagingMessage, toMessagingMessage
-
Constructor Details
-
AbstractMessagingMessageConverter
protected AbstractMessagingMessageConverter()
-
-
Method Details
-
setPayloadTypeMapper
Set the payload type mapper to be used by this converter.Message
payloads will be converted to theClass
returned by this function. ThedefaultHeaderTypeMapping(org.springframework.messaging.Message<?>)
uses thetypeHeader
property to retrieve the payload class' FQCN. This method replaces the default type mapping for this converter instance.- Parameters:
payloadTypeMapper
- the type mapping function.
-
setPayloadMessageConverter
Set theMessageConverter
to be used for converting theMessage
instances payloads.- Parameters:
messageConverter
- the converter instance.
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Set theObjectMapper
instance to be used for converting theMessage
instances payloads.- Parameters:
objectMapper
- the object mapper instance.
-
getPayloadMessageConverter
Get theMessageConverter
to be used for converting theMessage
instances payloads.- Returns:
- the instance.
-
setPayloadTypeHeader
Set the name of the header to be looked up in aMessage
instance by thedefaultHeaderTypeMapping(Message)
.- Parameters:
typeHeader
- the header name.
-
setPayloadTypeHeaderValueFunction
public void setPayloadTypeHeaderValueFunction(Function<Message<?>, String> payloadTypeHeaderFunction) Set the function to create the payload type header value from.- Parameters:
payloadTypeHeaderFunction
- the function.
-
setHeaderMapper
Set theHeaderMapper
to used to convert headers forMessage
instances.- Parameters:
headerMapper
- the header mapper instance.
-
doNotSendPayloadTypeHeader
public void doNotSendPayloadTypeHeader()Configure the converter to not include payload type information in theMessage
headers. -
createDefaultHeaderMapper
-
toMessagingMessage
Description copied from interface:ContextAwareMessagingMessageConverter
Convert a source message from a specific messaging system to aMessage
with an optional context.- Specified by:
toMessagingMessage
in interfaceContextAwareMessagingMessageConverter<S>
- Parameters:
message
- the source message.context
- an optional context with information to be used in the conversion process.- Returns:
- the converted message.
-
getPayloadToDeserialize
-
createMessageConversionContext
Description copied from interface:ContextAwareMessagingMessageConverter
An optional context to be used in the conversion process.- Specified by:
createMessageConversionContext
in interfaceContextAwareMessagingMessageConverter<S>
- Returns:
- the context.
-
fromMessagingMessage
Description copied from interface:ContextAwareMessagingMessageConverter
Convert aMessage
to a message from a specific messaging system.- Specified by:
fromMessagingMessage
in interfaceContextAwareMessagingMessageConverter<S>
- Parameters:
message
- the message from which to convert.context
- an optional context with information to be used in the conversion process.- Returns:
- the system specific message.
-
doConvertMessage
-