Package de.otto.synapse.eventsource
Interface EventSource
-
- All Known Implementing Classes:
AbstractEventSource,DefaultEventSource,DelegateEventSource
public interface EventSourceAn event source ofevents.Event sources can be consumed by
consumers.
-
-
Method Summary
Modifier and Type Method Description default java.util.concurrent.CompletableFuture<ChannelPosition>consume()Consumes all events from the EventSource, until the (current) end of the stream is reached.java.util.concurrent.CompletableFuture<ChannelPosition>consumeUntil(java.util.function.Predicate<ShardResponse> stopCondition)Consumes all messages from the EventSource until the predicate returns true.java.lang.StringgetChannelName()Returns the name of the EventSource.MessageDispatchergetMessageDispatcher()Returns the MessageDispatcher used by the EventSource to translate and sent incoming messages to the registeredmessage consumers.MessageLogReceiverEndpointgetMessageLogReceiverEndpoint()Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.booleanisStopping()voidregister(MessageConsumer<?> messageConsumer)Registers a new EventConsumer at the EventSource.voidstop()
-
-
-
Method Detail
-
register
void register(MessageConsumer<?> messageConsumer)
Registers a new EventConsumer at the EventSource.consumershave to be thread safe as it may be called from multiple threads (e.g. for kinesis streams there is one thread per shard)- Parameters:
messageConsumer- registered EventConsumer
-
getMessageDispatcher
@Nonnull MessageDispatcher getMessageDispatcher()
Returns the MessageDispatcher used by the EventSource to translate and sent incoming messages to the registeredmessage consumers.- Returns:
- MessageDispatcher
-
getMessageLogReceiverEndpoint
@Nonnull MessageLogReceiverEndpoint getMessageLogReceiverEndpoint()
Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.- Returns:
- MessageLogReceiverEndpoint
-
getChannelName
java.lang.String getChannelName()
Returns the name of the EventSource.For streaming event-sources, this is the name of the event stream.
- Returns:
- name
-
consume
default java.util.concurrent.CompletableFuture<ChannelPosition> consume()
Consumes all events from the EventSource, until the (current) end of the stream is reached.The registered
consumerswill be called zero or more times, depending on the number of events retrieved from the EventSource.- Returns:
- the new read position
-
consumeUntil
@Nonnull java.util.concurrent.CompletableFuture<ChannelPosition> consumeUntil(@Nonnull java.util.function.Predicate<ShardResponse> stopCondition)
Consumes all messages from the EventSource until the predicate returns true.The registered
consumerswill be called zero or more times, depending on the number of messages retrieved from the EventSource.- Parameters:
stopCondition- the stop condition used to determine whether or not message-consumption should stop- Returns:
- the new read position
-
stop
void stop()
-
isStopping
boolean isStopping()
-
-