public class ConsumerInterceptors<T> extends Object implements Closeable
ConsumerInterceptor and wraps calls to the chain
of custom interceptors.| Constructor and Description |
|---|
ConsumerInterceptors(List<ConsumerInterceptor<T>> interceptors) |
| Modifier and Type | Method and Description |
|---|---|
Message<T> |
beforeConsume(Consumer<T> consumer,
Message<T> message)
This is called just before the message is returned by
Consumer.receive(),
MessageListener.received(Consumer, Message) or the CompletableFuture
returned by Consumer.receiveAsync() completes. |
void |
close() |
void |
onAcknowledge(Consumer<T> consumer,
MessageId messageId,
Throwable exception)
This is called when acknowledge request return from the broker.
|
void |
onAcknowledgeCumulative(Consumer<T> consumer,
MessageId messageId,
Throwable exception)
This is called when acknowledge cumulative request return from the broker.
|
void |
onAckTimeoutSend(Consumer<T> consumer,
Set<MessageId> messageIds)
This is called when a redelivery from an acknowledge timeout occurs.
|
void |
onNegativeAcksSend(Consumer<T> consumer,
Set<MessageId> messageIds)
This is called when a redelivery from a negative acknowledge occurs.
|
public ConsumerInterceptors(List<ConsumerInterceptor<T>> interceptors)
public Message<T> beforeConsume(Consumer<T> consumer, Message<T> message)
Consumer.receive(),
MessageListener.received(Consumer, Message) or the CompletableFuture
returned by Consumer.receiveAsync() completes.
This method calls ConsumerInterceptor.beforeConsume(Consumer, Message) for each interceptor. Messages returned
from each interceptor get passed to beforeConsume() of the next interceptor in the chain of interceptors.
This method does not throw exceptions. If any of the interceptors in the chain throws an exception, it gets caught and logged, and next interceptor in int the chain is called with 'messages' returned by the previous successful interceptor beforeConsume call.
consumer - the consumer which contains the interceptorsmessage - message to be consume by the client.public void onAcknowledge(Consumer<T> consumer, MessageId messageId, Throwable exception)
This method calls ConsumerInterceptor.onAcknowledge(Consumer, MessageId, Throwable) method for each interceptor.
This method does not throw exceptions. Exceptions thrown by any of interceptors in the chain are logged, but not propagated.
consumer - the consumer which contains the interceptorsmessageId - message to acknowledge.exception - exception returned by broker.public void onAcknowledgeCumulative(Consumer<T> consumer, MessageId messageId, Throwable exception)
This method calls ConsumerInterceptor.onAcknowledgeCumulative(Consumer, MessageId, Throwable) (Message, Throwable)} method for each interceptor.
This method does not throw exceptions. Exceptions thrown by any of interceptors in the chain are logged, but not propagated.
consumer - the consumer which contains the interceptorsmessageId - messages to acknowledge.exception - exception returned by broker.public void onNegativeAcksSend(Consumer<T> consumer, Set<MessageId> messageIds)
This method calls onNegativeAcksSend(Consumer, Set<MessageId>) method for each interceptor.
This method does not throw exceptions. Exceptions thrown by any of interceptors in the chain are logged, but not propagated.
consumer - the consumer which contains the interceptors.messageIds - set of message IDs being redelivery due a negative acknowledge.public void onAckTimeoutSend(Consumer<T> consumer, Set<MessageId> messageIds)
This method calls onAckTimeoutSend(Consumer, Set<MessageId>) method for each interceptor.
This method does not throw exceptions. Exceptions thrown by any of interceptors in the chain are logged, but not propagated.
consumer - the consumer which contains the interceptors.messageIds - set of message IDs being redelivery due an acknowledge timeout.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2017–2021 Apache Software Foundation. All rights reserved.