Package de.otto.synapse.consumer
Class MessageDispatcher
java.lang.Object
de.otto.synapse.consumer.MessageDispatcher
- All Implemented Interfaces:
Consumer<TextMessage>
A MessageConsumer that is acting as a Message Dispatcher for multiple
message consumers.
As it is implementing the MessageConsumer interface, the MessageDispatcher is an implementation of the GoF Composite Pattern.
Messages are translated by the dispatcher using to the format expected by the registered consumers.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(TextMessage message) Accepts a message with JSON String payload, dispatches this method to the different registeredconsumersif theirMessageConsumer.keyPattern()matches, and translates the JSON payload into the expectedMessageConsumer.payloadType()of the receiving MessageConsumer.voidadd(MessageConsumer<?> messageConsumer) List<MessageConsumer<?>>getAll()Returns the pattern ofevent keysaccepted by this consumer.Returns the expected payload type ofeventsconsumed by this EventConsumer.
-
Constructor Details
-
MessageDispatcher
public MessageDispatcher() -
MessageDispatcher
-
-
Method Details
-
add
-
getAll
-
payloadType
Returns the expected payload type ofeventsconsumed by this EventConsumer.- Returns:
- payload type
-
keyPattern
Returns the pattern ofevent keysaccepted by this consumer.- Returns:
- Pattern
-
accept
Accepts a message with JSON String payload, dispatches this method to the different registeredconsumersif theirMessageConsumer.keyPattern()matches, and translates the JSON payload into the expectedMessageConsumer.payloadType()of the receiving MessageConsumer.- Specified by:
acceptin interfaceConsumer<TextMessage>- Parameters:
message- the input argument
-