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.time.Instant until)
Takes zero or more messages from the channel, calls
MessageEndpoint.intercept(Message) for every message, and notifies
the registered consumers with the intercepted message, or drops the message, if intercept returns null. |
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.
|
Message<java.lang.String> |
intercept(Message<java.lang.String> 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.time.Instant until)
MessageLogReceiverEndpointMessageEndpoint.intercept(Message) 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 consumptionuntil - the arrival timestamp until the messages should be consumedpublic 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 Message<java.lang.String> intercept(@Nonnull Message<java.lang.String> 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