Class DelegateMessageLogReceiverEndpoint
- All Implemented Interfaces:
MessageEndpoint,MessageLogReceiverEndpoint,MessageReceiverEndpoint
-
Constructor Summary
ConstructorsConstructorDescriptionDelegateMessageLogReceiverEndpoint(String channelName, Class<? extends Selector> selector, List<MessageLogReceiverEndpointFactory> factories) -
Method Summary
Modifier and TypeMethodDescriptionconsumeUntil(ChannelPosition startFrom, Predicate<ShardResponse> stopCondition) Beginning at thestartFromposition, messages are consumed from the message log, until thestopConditionis true.Returns the name of the channel.Returns theInterceptorChainof theMessageEndpoint.Returns the MessageDispatcher that is used to dispatch messages.intercept(TextMessage message) Intercepts a message using all registered interceptors and returns the resulting message.voidregister(MessageConsumer<?> messageConsumer) Registers a MessageConsumer at the receiver endpoint.voidstop()Stops consumption of messages and shuts down theMessageLogReceiverEndpoint.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.otto.synapse.endpoint.receiver.MessageLogReceiverEndpoint
consume
-
Constructor Details
-
DelegateMessageLogReceiverEndpoint
public DelegateMessageLogReceiverEndpoint(@Nonnull String channelName, @Nonnull Class<? extends Selector> selector, @Nonnull List<MessageLogReceiverEndpointFactory> factories)
-
-
Method Details
-
consumeUntil
@Nonnull public CompletableFuture<ChannelPosition> consumeUntil(@Nonnull ChannelPosition startFrom, @Nonnull Predicate<ShardResponse> stopCondition) Description copied from interface:MessageLogReceiverEndpointBeginning 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.- Specified by:
consumeUntilin interfaceMessageLogReceiverEndpoint- 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
public void stop()Description copied from interface:MessageLogReceiverEndpointStops consumption of messages and shuts down theMessageLogReceiverEndpoint.- Specified by:
stopin interfaceMessageLogReceiverEndpoint
-
register
Description copied from interface:MessageReceiverEndpointRegisters a MessageConsumer at the receiver endpoint.consumershave 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).- Specified by:
registerin interfaceMessageReceiverEndpoint- Parameters:
messageConsumer- registered EventConsumer
-
getMessageDispatcher
Description copied from interface:MessageReceiverEndpointReturns the MessageDispatcher that is used to dispatch messages.- Specified by:
getMessageDispatcherin interfaceMessageReceiverEndpoint- Returns:
- MessageDispatcher
-
getChannelName
Description copied from interface:MessageEndpointReturns the name of the channel.The channel name corresponds to the name of the underlying stream, queue or message log.
- Specified by:
getChannelNamein interfaceMessageEndpoint- Returns:
- name of the channel
-
getInterceptorChain
Description copied from interface:MessageEndpointReturns theInterceptorChainof theMessageEndpoint.- Specified by:
getInterceptorChainin interfaceMessageEndpoint- Returns:
- InterceptorChain
-
getEndpointType
Description copied from interface:MessageEndpoint- Specified by:
getEndpointTypein interfaceMessageEndpoint- Returns:
- EndpointType
-
intercept
Description copied from interface:MessageEndpointIntercepts a message using all registered interceptors and returns the resulting message.The 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
nullis returned, the message must be dropped by theAbstractMessageEndpoint.Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.
- Specified by:
interceptin interfaceMessageEndpoint- Parameters:
message- the message to intercept- Returns:
- the (possibly modified) message, or null if the message should be dropped.
-
getDelegate
-