Package de.otto.synapse.consumer
Interface MessageConsumer<T>
-
- Type Parameters:
T- the type of the messages's payload
- All Superinterfaces:
java.util.function.Consumer<Message<T>>
- All Known Implementing Classes:
MethodInvokingMessageConsumer,StatefulMessageConsumer
@ThreadSafe public interface MessageConsumer<T> extends java.util.function.Consumer<Message<T>>
A consumer endpoint formessageswith payload-type <T>.
Multiple EventConsumers may listen at a single
EventSource. A single EventConsumer must be registered to multiple EventSources.By default, Synapse is auto-configuring a
EventSourceConsumerProcessthat is running a separate thread for every MessageConsumer. The thread is taking care for continuous consumption of messages using the consumers, until the application is shutting down.If you need to manually consume messages using MessageConsumers, auto-configuration of the
EventSourceConsumerProcesscan be disabled by settingsynapse.consumer-process.enabled=falseMessageConsumers are expected to be thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.regex.PatternkeyPattern()Returns the pattern ofmessage keysaccepted by this consumer.static <T> MessageConsumer<T>of(java.lang.String keyPattern, java.lang.Class<T> payloadType, java.util.function.Consumer<Message<T>> consumer)java.lang.Class<T>payloadType()Returns the expected payload type ofeventsconsumed by this EventConsumer.
-
-
-
Method Detail
-
of
static <T> MessageConsumer<T> of(java.lang.String keyPattern, java.lang.Class<T> payloadType, java.util.function.Consumer<Message<T>> consumer)
-
payloadType
@Nonnull java.lang.Class<T> payloadType()
Returns the expected payload type ofeventsconsumed by this EventConsumer.- Returns:
- payload type
-
keyPattern
@Nonnull java.util.regex.Pattern keyPattern()
Returns the pattern ofmessage keysaccepted by this consumer.- Returns:
- Pattern
-
-