pub trait ProducerContext<Part: Partitioner = NoCustomPartitioner>: ClientContext {
    type DeliveryOpaque: IntoOpaque;

    // Required method
    fn delivery(
        &self,
        delivery_result: &DeliveryResult<'_>,
        delivery_opaque: Self::DeliveryOpaque
    );

    // Provided method
    fn get_custom_partitioner(&self) -> Option<&Part> { ... }
}
Expand description

Producer-specific context.

This user-defined object can be used to provide custom callbacks for producer events. Refer to the list of methods to check which callbacks can be specified. It can also specify custom partitioner to register and to be used for deciding to which partition write message into.

In particular, it can be used to specify the delivery callback that will be called when the acknowledgement for a delivered message is received.

See also the ClientContext trait.

Required Associated Types§

source

type DeliveryOpaque: IntoOpaque

A DeliveryOpaque is a user-defined structure that will be passed to the producer when producing a message, and returned to the delivery method once the message has been delivered, or failed to.

Required Methods§

source

fn delivery( &self, delivery_result: &DeliveryResult<'_>, delivery_opaque: Self::DeliveryOpaque )

This method will be called once the message has been delivered (or failed to). The DeliveryOpaque will be the one provided by the user when calling send.

Provided Methods§

source

fn get_custom_partitioner(&self) -> Option<&Part>

This method is called when creating producer in order to optionally register custom partitioner. If custom partitioner is not used then partitioner configuration property is used (or its default).

sticky.partitioning.linger.ms must be 0 to run custom partitioner for messages with null key. See https://github.com/confluentinc/librdkafka/blob/081fd972fa97f88a1e6d9a69fc893865ffbb561a/src/rdkafka_msg.c#L1192-L1196

Object Safety§

This trait is not object safe.

Implementors§