T - the type of the messages's payload@ThreadSafe public interface MessageConsumer<T> extends java.util.function.Consumer<Message<T>>
messages with 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 EventSourceConsumerProcess that 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
EventSourceConsumerProcess can be disabled by setting
synapse.consumer-process.enabled=false
MessageConsumers are expected to be thread-safe.
| Modifier and Type | Method and Description |
|---|---|
java.util.regex.Pattern |
keyPattern()
Returns the pattern of
message keys accepted 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 of
events consumed by this EventConsumer. |
static <T> MessageConsumer<T> of(java.lang.String keyPattern, java.lang.Class<T> payloadType, java.util.function.Consumer<Message<T>> consumer)
@Nonnull java.lang.Class<T> payloadType()
events consumed by this EventConsumer.@Nonnull java.util.regex.Pattern keyPattern()
message keys accepted by this consumer.