类 ProducerInterceptorWrapper
- java.lang.Object
-
- org.apache.pulsar.client.api.interceptor.ProducerInterceptorWrapper
-
- 所有已实现的接口:
java.lang.AutoCloseable,ProducerInterceptor
@Private @Stable public class ProducerInterceptorWrapper extends java.lang.Object implements ProducerInterceptor
A wrapper for old style producer interceptor.
-
-
构造器概要
构造器 构造器 说明 ProducerInterceptorWrapper(ProducerInterceptor<?> innerInterceptor)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 MessagebeforeSend(Producer producer, Message message)This is called fromProducer.send(Object)andProducer.sendAsync(Object)methods, before send the message to the brokers.voidclose()Close the interceptor.booleaneligible(Message message)Check whether the interceptor is eligible for this message.voidonSendAcknowledgement(Producer producer, Message message, MessageId msgId, java.lang.Throwable exception)This method is called when the message sent to the broker has been acknowledged, or when sending the message fails.
-
-
-
构造器详细资料
-
ProducerInterceptorWrapper
public ProducerInterceptorWrapper(ProducerInterceptor<?> innerInterceptor)
-
-
方法详细资料
-
close
public void close()
从接口复制的说明:ProducerInterceptorClose the interceptor.- 指定者:
close在接口中java.lang.AutoCloseable- 指定者:
close在接口中ProducerInterceptor
-
eligible
public boolean eligible(Message message)
从接口复制的说明:ProducerInterceptorCheck whether the interceptor is eligible for this message.- 指定者:
eligible在接口中ProducerInterceptor- 参数:
message- message to send- 返回:
- whether the interceptor can be applied to this particular message.
-
beforeSend
public Message beforeSend(Producer producer, Message message)
从接口复制的说明:ProducerInterceptorThis is called fromProducer.send(Object)andProducer.sendAsync(Object)methods, before send the message to the brokers. This method is allowed to modify the record, in which case, the new record will be returned.Any exception thrown by this method will be caught by the caller and logged, but not propagated further.
Each interceptor will be passed the message returned by the last successful executed interceptor or the original message if it is the first one. Since interceptors are allowed to modify messages, interceptors may potentially get the message already modified by other interceptors. However, building a pipeline of mutable interceptors that depend on the output of the previous interceptor is discouraged, because of potential side-effects caused by interceptors potentially failing to modify the message and throwing an exception.
- 指定者:
beforeSend在接口中ProducerInterceptor- 参数:
producer- the producer which contains the interceptor.message- message to send- 返回:
- the intercepted message
-
onSendAcknowledgement
public void onSendAcknowledgement(Producer producer, Message message, MessageId msgId, java.lang.Throwable exception)
从接口复制的说明:ProducerInterceptorThis method is called when the message sent to the broker has been acknowledged, or when sending the message fails. This method is generally called just before the user callback is called, and in additional cases when an exception on the producer side.Any exception thrown by this method will be ignored by the caller.
This method will generally execute in the background I/O thread, so the implementation should be reasonably fast. Otherwise, sending of messages from other threads could be delayed.
- 指定者:
onSendAcknowledgement在接口中ProducerInterceptor- 参数:
producer- the producer which contains the interceptor.message- the message that application sendsmsgId- the message id that assigned by the broker; null if send failed.exception- the exception on sending messages, null indicates send has succeed.
-
-