public class DelegateMessageLogReceiverEndpoint extends java.lang.Object implements MessageLogReceiverEndpoint
| Constructor and Description |
|---|
DelegateMessageLogReceiverEndpoint(java.lang.String channelName,
MessageLogReceiverEndpointFactory messageLogReceiverEndpointFactory) |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<ChannelPosition> |
consumeUntil(ChannelPosition startFrom,
java.util.function.Predicate<ShardResponse> stopCondition)
Beginning at the
startFrom position, messages are consumed from the message log, until the
stopCondition is true. |
java.lang.String |
getChannelName()
Returns the name of the channel.
|
EndpointType |
getEndpointType()
|
InterceptorChain |
getInterceptorChain()
Returns the
InterceptorChain of the MessageEndpoint. |
MessageDispatcher |
getMessageDispatcher()
Returns the MessageDispatcher that is used to dispatch messages.
|
TextMessage |
intercept(TextMessage message)
Intercepts a message using all registered interceptors and returns the resulting message.
|
void |
register(MessageConsumer<?> messageConsumer)
Registers a MessageConsumer at the receiver endpoint.
|
void |
stop()
Stops consumption of messages and shuts down the
MessageLogReceiverEndpoint. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconsumepublic DelegateMessageLogReceiverEndpoint(@Nonnull
java.lang.String channelName,
@Nonnull
MessageLogReceiverEndpointFactory messageLogReceiverEndpointFactory)
@Nonnull public java.util.concurrent.CompletableFuture<ChannelPosition> consumeUntil(@Nonnull ChannelPosition startFrom, @Nonnull java.util.function.Predicate<ShardResponse> stopCondition)
MessageLogReceiverEndpointstartFrom position, messages are consumed from the message log, until the
stopCondition is 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, if
intercept returns null.
Consumption starts with the first message after startFrom and finishes when either the
stopCondition is met, or the application is shutting down.
The returned ChannelPosition is the position of the last message that was processed by the
MessageLogReceiverEndpoint - whether it was dropped or consumed.
The registered consumers are used as a
callback for consumed messages. A MessageDispatcher can be used as a consumer, if multiple
consumers, or consumers with message payloads other than String are
required.
consumeUntil in interface MessageLogReceiverEndpointstartFrom - 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 in StopCondition should be sufficient.public void stop()
MessageLogReceiverEndpointMessageLogReceiverEndpoint.stop in interface MessageLogReceiverEndpointpublic void register(MessageConsumer<?> messageConsumer)
MessageReceiverEndpointconsumers have to be thread safe as they might be called from multiple threads
in parallel (e.g. for kinesis streams there is one thread per shard).register in interface MessageReceiverEndpointmessageConsumer - registered EventConsumer@Nonnull public MessageDispatcher getMessageDispatcher()
MessageReceiverEndpointgetMessageDispatcher in interface MessageReceiverEndpoint@Nonnull public java.lang.String getChannelName()
MessageEndpointThe channel name corresponds to the name of the underlying stream, queue or message log.
getChannelName in interface MessageEndpoint@Nonnull public InterceptorChain getInterceptorChain()
MessageEndpointInterceptorChain of the MessageEndpoint.getInterceptorChain in interface MessageEndpoint@Nonnull public EndpointType getEndpointType()
MessageEndpointgetEndpointType in interface MessageEndpoint@Nullable public TextMessage intercept(@Nonnull TextMessage message)
MessageEndpointThe interceptors are called in order. The result of one interceptor is propagated to the next interceptor in the chain, until the end of the chain is reached, or one interceptor has returned null.
If null is returned, the message must be dropped by the AbstractMessageEndpoint.
Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.
intercept in interface MessageEndpointmessage - the message to intercept