Interface MessageLogReceiverEndpoint
- All Superinterfaces:
MessageEndpoint,MessageReceiverEndpoint
- All Known Implementing Classes:
AbstractMessageLogReceiverEndpoint,DelegateMessageLogReceiverEndpoint
public interface MessageLogReceiverEndpoint extends MessageReceiverEndpoint
MessageEndpoint endpoint of a Message Channel that matches random-access like reading of
messages using ChannelPositions.
MessageLogReceiverEndpoints are endpoints for Publish-Subscribe Channels:
- See Also:
- EIP: Publish-Subscribe Channel
-
Method Summary
Modifier and Type Method Description default java.util.concurrent.CompletableFuture<ChannelPosition>consume(ChannelPosition startFrom)Beginning at thestartFromposition, messages are consumed from the message log, until thestopConditionis true.java.util.concurrent.CompletableFuture<ChannelPosition>consumeUntil(ChannelPosition startFrom, java.util.function.Predicate<ShardResponse> stopCondition)Beginning at thestartFromposition, messages are consumed from the message log, until thestopConditionis true.voidstop()Stops consumption of messages and shuts down theMessageLogReceiverEndpoint.Methods inherited from interface de.otto.synapse.endpoint.MessageEndpoint
getChannelName, getEndpointType, getInterceptorChain, interceptMethods inherited from interface de.otto.synapse.endpoint.receiver.MessageReceiverEndpoint
getMessageDispatcher, register
-
Method Details
-
consume
@Nonnull default java.util.concurrent.CompletableFuture<ChannelPosition> consume(@Nonnull ChannelPosition startFrom)Beginning at thestartFromposition, messages are consumed from the message log, until thestopConditionis true.Takes zero or more messages from the channel, calls
MessageEndpoint.intercept(TextMessage)for every message, and notifies the registered consumers with the intercepted message, or drops the message, ifinterceptreturns null.Consumption starts with the first message after
startFromand finishes when either thestopConditionis met, or the application is shutting down.The returned
ChannelPositionis the position of the last message that was processed by theMessageLogReceiverEndpoint- whether it was dropped or consumed.The
registeredconsumersare used as a callback for consumed messages.- Parameters:
startFrom- the start position used to proceed message consumption- Returns:
- ChannelPosition
-
consumeUntil
@Nonnull java.util.concurrent.CompletableFuture<ChannelPosition> consumeUntil(@Nonnull ChannelPosition startFrom, @Nonnull java.util.function.Predicate<ShardResponse> stopCondition)Beginning at thestartFromposition, messages are consumed from the message log, until thestopConditionis true.If the message-log is sharded, the predicate must be true for every shard: otherwise, message consumption would continue on other shards.
Takes zero or more messages from the channel, calls
MessageEndpoint.intercept(TextMessage)for every message, and notifies the registered consumers with the intercepted message, or drops the message, ifinterceptreturns null.Consumption starts with the first message after
startFromand finishes when either thestopConditionis met, or the application is shutting down.The returned
ChannelPositionis the position of the last message that was processed by theMessageLogReceiverEndpoint- whether it was dropped or consumed.The
registeredconsumersare used as a callback for consumed messages. AMessageDispatchercan be used as a consumer, if multiple consumers, or consumers withmessage payloadsother thanStringare required.- Parameters:
startFrom- the start position used to proceed message consumptionstopCondition- the predicate used to test if message consumption should be stopped. In most cases, the predicates defined inStopConditionshould be sufficient.- Returns:
- ChannelPosition
-
stop
void stop()Stops consumption of messages and shuts down theMessageLogReceiverEndpoint.
-