Interface MessageConsumer<T>

Type Parameters:
T - the type of the messages's payload
All Superinterfaces:
Consumer<Message<T>>
All Known Implementing Classes:
MethodInvokingMessageConsumer, StatefulMessageConsumer

public interface MessageConsumer<T> extends 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 Details

    • of

      static <T> MessageConsumer<T> of(String keyPattern, Class<T> payloadType, Consumer<Message<T>> consumer)
    • payloadType

      @Nonnull Class<T> payloadType()
      Returns the expected payload type of events consumed by this EventConsumer.
      Returns:
      payload type
    • keyPattern

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