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 for messages with payload-type <T>.

MesageConsumer

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.

  • Method Summary

    Modifier and Type Method 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.

    Methods inherited from interface java.util.function.Consumer

    accept, andThen
  • Method Details

    • 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 of events consumed by this EventConsumer.
      Returns:
      payload type
    • keyPattern

      @Nonnull java.util.regex.Pattern keyPattern()
      Returns the pattern of message keys accepted by this consumer.
      Returns:
      Pattern