Package de.otto.synapse.translator
Class TextMessageTranslator
- java.lang.Object
-
- de.otto.synapse.translator.TextMessageTranslator
-
- All Implemented Interfaces:
MessageTranslator<TextMessage>,java.util.function.Function<Message<?>,TextMessage>
public class TextMessageTranslator extends java.lang.Object implements MessageTranslator<TextMessage>
A MessageTranslator that converts messages intoTextMessage.The Message Translator is the messaging equivalent of the Adapter pattern described in [GoF]. An adapter converts the interface of a component into a another interface so it can be used in a different context.

This implementation is relying on
ObjectMappers.currentObjectMapper()to transform message payloads with non-String payload into a JSON payload.
-
-
Constructor Summary
Constructors Constructor Description TextMessageTranslator()
-
Method Summary
Modifier and Type Method Description TextMessageapply(Message<?> message)Translates a Message into a Message with payload-type <String> and serializes the payload into a JSON String.
-
-
-
Method Detail
-
apply
@Nonnull public TextMessage apply(@Nonnull Message<?> message)
Translates a Message into a Message with payload-type <String> and serializes the payload into a JSON String.- Specified by:
applyin interfacejava.util.function.Function<Message<?>,TextMessage>- Specified by:
applyin interfaceMessageTranslator<TextMessage>- Parameters:
message- Message<?>- Returns:
- Message<String>
-
-