public class DelegateMessageQueueReceiverEndpoint extends java.lang.Object implements MessageQueueReceiverEndpoint
| Constructor and Description |
|---|
DelegateMessageQueueReceiverEndpoint(java.lang.String channelName,
MessageQueueReceiverEndpointFactory messageQueueReceiverEndpointFactory) |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<java.lang.Void> |
consume()
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
MessageQueueReceiverEndpoint. |
public DelegateMessageQueueReceiverEndpoint(@Nonnull
java.lang.String channelName,
@Nonnull
MessageQueueReceiverEndpointFactory messageQueueReceiverEndpointFactory)
public java.util.concurrent.CompletableFuture<java.lang.Void> consume()
MessageQueueReceiverEndpointMessageEndpoint.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 earliest available and not-yet-consumed message and finishes when either the
stopCondition is met, or the application is shutting down.
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.
consume in interface MessageQueueReceiverEndpointwait until the endpoint has
stopped message consumption.public void stop()
MessageQueueReceiverEndpointMessageQueueReceiverEndpoint.stop in interface MessageQueueReceiverEndpointpublic 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