Class DelegateEventSource

  • All Implemented Interfaces:
    EventSource

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

      • DelegateEventSource

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

      • 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
      • 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
      • toString

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