Package de.otto.synapse.eventsource
Class DelegateEventSource
java.lang.Object
de.otto.synapse.eventsource.DelegateEventSource
- All Implemented Interfaces:
EventSource
-
Constructor Summary
ConstructorsConstructorDescriptionDelegateEventSource(String messageLogBeanName, Class<? extends MessageLog> selector, List<EventSourceBuilder> eventSourceBuilder, org.springframework.context.ApplicationContext applicationContext) -
Method Summary
Modifier and TypeMethodDescriptionconsume()Consumes all events from the EventSource, until the (current) end of the stream is reached.consumeUntil(Predicate<ShardResponse> stopCondition) Consumes all events from the EventSource until the timestamp is reached.Returns the name of the EventSource.Returns registered EventConsumers.Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.booleanvoidregister(MessageConsumer<?> messageConsumer) Registers a new EventConsumer at the EventSource.voidstop()toString()
-
Constructor Details
-
DelegateEventSource
public DelegateEventSource(String messageLogBeanName, Class<? extends MessageLog> selector, List<EventSourceBuilder> eventSourceBuilder, org.springframework.context.ApplicationContext applicationContext)
-
-
Method Details
-
getDelegate
-
register
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
Returns registered EventConsumers.- Specified by:
getMessageDispatcherin interfaceEventSource- Returns:
- EventConsumers
-
getMessageLogReceiverEndpoint
Returns the MessageLogReceiverEndpoint used by theEventSourceto consume events.- Specified by:
getMessageLogReceiverEndpointin interfaceEventSource- Returns:
- MessageLogReceiverEndpoint
-
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
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 CompletableFuture<ChannelPosition> consumeUntil(@Nonnull 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
-