public class ProducerInterceptors extends Object implements Closeable
ProducerInterceptor
and wraps calls to the chain of custom interceptors.| Constructor and Description |
|---|
ProducerInterceptors(List<ProducerInterceptor> interceptors) |
| Modifier and Type | Method and Description |
|---|---|
Message |
beforeSend(Producer producer,
Message message)
This is called when client sends message to pulsar broker, before key and value gets serialized.
|
void |
close() |
void |
onSendAcknowledgement(Producer producer,
Message message,
MessageId msgId,
Throwable exception)
This method is called when the message send to the broker has been acknowledged, or when sending the record fails
before it gets send to the broker.
|
public ProducerInterceptors(List<ProducerInterceptor> interceptors)
public Message beforeSend(Producer producer, Message message)
ProducerInterceptor.beforeSend(Producer,Message) method. Message returned from
first interceptor's beforeSend() is passed to the second interceptor beforeSend(), and so on in the
interceptor chain. The message returned from the last interceptor is returned from this method.
This method does not throw exceptions. Exceptions thrown by any interceptor methods are caught and ignored.
If a interceptor in the middle of the chain, that normally modifies the message, throws an exception,
the next interceptor in the chain will be called with a message returned by the previous interceptor that did
not throw an exception.producer - the producer which contains the interceptor.message - the message from clientpublic void onSendAcknowledgement(Producer producer, Message message, MessageId msgId, Throwable exception)
ProducerInterceptor.onSendAcknowledgement(Producer, Message, MessageId, Throwable) method for
each interceptor.
This method does not throw exceptions. Exceptions thrown by any of interceptor methods are caught and ignored.producer - the producer which contains the interceptor.message - The message returned from the last interceptor is returned from ProducerInterceptor.beforeSend(Producer, Message)msgId - The message id that broker returned. Null if has error occurred.exception - The exception thrown during processing of this message. Null if no error occurred.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2017–2021 Apache Software Foundation. All rights reserved.