类 ProducerInterceptors

java.lang.Object
org.apache.pulsar.client.impl.ProducerInterceptors
所有已实现的接口:
Closeable, AutoCloseable

public class ProducerInterceptors extends Object implements Closeable
A container that holds the listProducerInterceptor and wraps calls to the chain of custom interceptors.
  • 构造器详细资料

  • 方法详细资料

    • beforeSend

      public Message beforeSend(Producer producer, Message message)
      This is called when client sends message to pulsar broker, before key and value gets serialized. The method calls 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 client
      返回:
      the message to send to topic/partition
    • onSendAcknowledgement

      public 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. This method calls 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.
    • onPartitionsChange

      public void onPartitionsChange(String topicName, int partitions)
    • close

      public void close() throws IOException
      指定者:
      close 在接口中 AutoCloseable
      指定者:
      close 在接口中 Closeable
      抛出:
      IOException