pub trait ConsumerInterceptor:
Send
+ Sync
+ Debug {
// Required method
fn before_consume(&self, msg: &mut IncomingMessage);
// Provided methods
fn on_acknowledge(
&self,
_message_id: MessageId,
_outcome: Result<(), &PulsarError>,
) { ... }
fn on_acknowledge_cumulative(
&self,
_message_id: MessageId,
_outcome: Result<(), &PulsarError>,
) { ... }
fn on_negative_acks_send(&self, _message_ids: &[MessageId]) { ... }
}Expand description
Java ConsumerInterceptor SPI. Plug receive-side hooks behind Consumer::receive
to inspect / mutate incoming messages and observe ack outcomes. Mirrors
org.apache.pulsar.client.api.interceptor.ConsumerInterceptor:
before_consumeruns on every received message and may mutate it.on_acknowledgefires on every individual / batch ack.on_acknowledge_cumulativefires on every cumulative ack.on_negative_acks_sendfires when the runtime forwards a redeliver-unacknowledged command (negative ack with delay or immediate).
Each callback runs on the receive / ack path — keep them fast and non-blocking. Use
receive_with_interceptors to chain a list against a magnetar_runtime_tokio::Consumer.
Required Methods§
Sourcefn before_consume(&self, msg: &mut IncomingMessage)
fn before_consume(&self, msg: &mut IncomingMessage)
Inspect and optionally mutate the incoming message before it is handed back to
the user. Mirrors Java ConsumerInterceptor#beforeConsume.
Provided Methods§
Sourcefn on_acknowledge(
&self,
_message_id: MessageId,
_outcome: Result<(), &PulsarError>,
)
fn on_acknowledge( &self, _message_id: MessageId, _outcome: Result<(), &PulsarError>, )
Fired after an individual or batch ack completes (success or error). Mirrors Java
ConsumerInterceptor#onAcknowledge.
Sourcefn on_acknowledge_cumulative(
&self,
_message_id: MessageId,
_outcome: Result<(), &PulsarError>,
)
fn on_acknowledge_cumulative( &self, _message_id: MessageId, _outcome: Result<(), &PulsarError>, )
Fired after a cumulative ack completes. Mirrors Java
ConsumerInterceptor#onAcknowledgeCumulative.
Sourcefn on_negative_acks_send(&self, _message_ids: &[MessageId])
fn on_negative_acks_send(&self, _message_ids: &[MessageId])
Fired when the runtime forwards a CommandRedeliverUnacknowledgedMessages for one
or more message ids. Mirrors Java ConsumerInterceptor#onNegativeAcksSend.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".