Class GenericMessageConverter
java.lang.Object
com.github.sonus21.rqueue.converter.GenericMessageConverter
- All Implemented Interfaces:
org.springframework.messaging.converter.MessageConverter,org.springframework.messaging.converter.SmartMessageConverter
public class GenericMessageConverter
extends Object
implements org.springframework.messaging.converter.SmartMessageConverter
A converter to turn the payload of a
Message from serialized form to a typed String and
vice versa. This class does not support generic class except List,even for list the
entries should be non generic.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromMessage(org.springframework.messaging.Message<?> message, Class<?> targetClass) Convert the payload of aMessagefrom a serialized form to a typed Object of type stored in message it self.fromMessage(org.springframework.messaging.Message<?> message, Class<?> targetClass, Object conversionHint) org.springframework.messaging.Message<?> Create aMessagewhose payload is the result of converting the given payload Object to serialized form.org.springframework.messaging.Message<?> toMessage(Object payload, org.springframework.messaging.MessageHeaders headers, Object conversionHint)
-
Constructor Details
-
GenericMessageConverter
public GenericMessageConverter() -
GenericMessageConverter
public GenericMessageConverter(tools.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
toMessage
public org.springframework.messaging.Message<?> toMessage(Object payload, org.springframework.messaging.MessageHeaders headers) Create aMessagewhose payload is the result of converting the given payload Object to serialized form. It ignores all headers components.If the converter cannot perform the conversion, it return
null.- Specified by:
toMessagein interfaceorg.springframework.messaging.converter.MessageConverter- Parameters:
payload- the Object to convertheaders- optional headers for the message (may benull)- Returns:
- the new message, or
null
-
fromMessage
public Object fromMessage(org.springframework.messaging.Message<?> message, Class<?> targetClass, Object conversionHint) - Specified by:
fromMessagein interfaceorg.springframework.messaging.converter.SmartMessageConverter
-
toMessage
public org.springframework.messaging.Message<?> toMessage(Object payload, org.springframework.messaging.MessageHeaders headers, Object conversionHint) - Specified by:
toMessagein interfaceorg.springframework.messaging.converter.SmartMessageConverter
-
fromMessage
Convert the payload of aMessagefrom a serialized form to a typed Object of type stored in message it self.If the converter cannot perform the conversion it returns
null.- Specified by:
fromMessagein interfaceorg.springframework.messaging.converter.MessageConverter- Parameters:
message- the input messagetargetClass- the target class for the conversion- Returns:
- the result of the conversion, or
nullif the converter cannot perform the conversion.
-