Class DelegateEventSource

java.lang.Object
de.otto.synapse.eventsource.DelegateEventSource
All Implemented Interfaces:
EventSource

public class DelegateEventSource
extends java.lang.Object
implements EventSource
  • Constructor Details

    • DelegateEventSource

      public DelegateEventSource​(java.lang.String messageLogBeanName, EventSourceBuilder eventSourceBuilder, org.springframework.context.ApplicationContext applicationContext)
  • Method Details

    • getDelegate

      public EventSource getDelegate()
    • register

      public void register​(MessageConsumer<?> messageConsumer)
      Registers a new EventConsumer at the EventSource.

      consumers have to be thread safe as it may be called from multiple threads (e.g. for kinesis streams there is one thread per shard)

      Specified by:
      register in interface EventSource
      Parameters:
      messageConsumer - the registered EventConsumer
    • getMessageDispatcher

      @Nonnull public MessageDispatcher getMessageDispatcher()
      Returns registered EventConsumers.
      Specified by:
      getMessageDispatcher in interface EventSource
      Returns:
      EventConsumers
    • getMessageLogReceiverEndpoint

      @Nonnull public MessageLogReceiverEndpoint getMessageLogReceiverEndpoint()
      Returns the MessageLogReceiverEndpoint used by the EventSource to consume events.
      Specified by:
      getMessageLogReceiverEndpoint in interface EventSource
      Returns:
      MessageLogReceiverEndpoint
    • getChannelName

      @Nonnull public java.lang.String getChannelName()
      Returns the name of the EventSource.

      For streaming event-sources, this is the name of the event stream.

      Specified by:
      getChannelName in interface EventSource
      Returns:
      name
    • consume

      public java.util.concurrent.CompletableFuture<ChannelPosition> consume()
      Consumes all events from the EventSource, until the (current) end of the stream is reached.

      The registered consumers will be called zero or more times, depending on the number of events retrieved from the EventSource.

      Specified by:
      consume in interface EventSource
      Returns:
      the new read position
    • consumeUntil

      @Nonnull public java.util.concurrent.CompletableFuture<ChannelPosition> consumeUntil​(@Nonnull java.util.function.Predicate<ShardResponse> stopCondition)
      Consumes all events from the EventSource until the timestamp is reached.

      The registered consumers will be called zero or more times, depending on the number of events retrieved from the EventSource.

      Specified by:
      consumeUntil in interface EventSource
      Parameters:
      stopCondition - the stop condition used to determine whether or not message-consumption should stop
      Returns:
      the new read position
    • stop

      public void stop()
      Specified by:
      stop in interface EventSource
    • isStopping

      public boolean isStopping()
      Specified by:
      isStopping in interface EventSource
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object