Package de.otto.synapse.eventsource
Class DelegateEventSource
- java.lang.Object
-
- de.otto.synapse.eventsource.DelegateEventSource
-
- All Implemented Interfaces:
EventSource
public class DelegateEventSource extends java.lang.Object implements EventSource
-
-
Constructor Summary
Constructors Constructor Description DelegateEventSource(java.lang.String messageLogBeanName, EventSourceBuilder eventSourceBuilder, org.springframework.context.ApplicationContext applicationContext)
-
Method Summary
Modifier and Type Method Description 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 events from the EventSource until the timestamp is reached.java.lang.StringgetChannelName()Returns the name of the EventSource.EventSourcegetDelegate()MessageDispatchergetMessageDispatcher()Returns registered EventConsumers.MessageLogReceiverEndpointgetMessageLogReceiverEndpoint()Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.booleanisStopping()voidregister(MessageConsumer<?> messageConsumer)Registers a new EventConsumer at the EventSource.voidstop()java.lang.StringtoString()
-
-
-
Constructor Detail
-
DelegateEventSource
public DelegateEventSource(java.lang.String messageLogBeanName, EventSourceBuilder eventSourceBuilder, org.springframework.context.ApplicationContext applicationContext)
-
-
Method Detail
-
getDelegate
public EventSource getDelegate()
-
register
public 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)- Specified by:
registerin interfaceEventSource- Parameters:
messageConsumer- the registered EventConsumer
-
getMessageDispatcher
@Nonnull public MessageDispatcher getMessageDispatcher()
Returns registered EventConsumers.- Specified by:
getMessageDispatcherin interfaceEventSource- Returns:
- EventConsumers
-
getMessageLogReceiverEndpoint
@Nonnull public MessageLogReceiverEndpoint getMessageLogReceiverEndpoint()
Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.- Specified by:
getMessageLogReceiverEndpointin interfaceEventSource- 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:
getChannelNamein interfaceEventSource- 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
consumerswill be called zero or more times, depending on the number of events retrieved from the EventSource.- Specified by:
consumein interfaceEventSource- 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
consumerswill be called zero or more times, depending on the number of events retrieved from the EventSource.- Specified by:
consumeUntilin interfaceEventSource- 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:
stopin interfaceEventSource
-
isStopping
public boolean isStopping()
- Specified by:
isStoppingin interfaceEventSource
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-