Skip to main content

PartitionedConsumerBuilder

Struct PartitionedConsumerBuilder 

Source
pub struct PartitionedConsumerBuilder<'a, E: Engine = TokioEngine> { /* private fields */ }
Expand description

Builder for a partition-aware consumer.

Generic over E: crate::Engine (default crate::TokioEngine). The .subscribe() method routes through crate::MultiTopicsConsumerBuilder so each per-partition child uses the engine’s concrete consumer type.

Implementations§

Source§

impl<'a, E: Engine> PartitionedConsumerBuilder<'a, E>

Source

pub fn message_listener(self, listener: WrapperMessageListener) -> Self

Register a push-delivery callback (Java ConsumerBuilder#messageListener at the partitioned scope). Once set, subscribe via Self::subscribe_with_listener to start a background poller over the per-partition consumer set, handing every message to listener sequentially and in order, with no auto-ack. The callback receives the originating partition topic so it can ack against the right child. The plain Self::subscribe ignores the listener and returns a pull-mode consumer.

Source

pub fn subscription(self, name: impl Into<String>) -> Self

Required: set the subscription name (shared across every per-partition child consumer).

Source

pub fn name(self, name: impl Into<String>) -> Self

Mirrors ConsumerBuilder::name. The name is propagated verbatim to every per-partition child consumer (no per-partition suffix), so each child subscribes with the same consumer_name and broker topics stats reports it for every partition — matching the Java client and letting you attribute a Failover-active consumer to an instance. Default None lets the broker assign a name.

Source

pub fn subscription_type(self, sub_type: SubType) -> Self

Set the subscription type for every per-partition child consumer.

Source

pub fn receiver_queue_size(self, size: usize) -> Self

Per-partition receiver queue size.

Source

pub fn receiver_queue_policy(self, policy: Arc<dyn ReceiverQueuePolicy>) -> Self

Set a pluggable receiver-queue-size policy (issue #301) applied to every per-partition child. The byte budget on magnetar_proto::Auto is divided across the live partition count inside the policy’s adjust, so the aggregate buffered bytes across all partitions stay within max_bytes. Enabling a policy turns on auto-adjust with a default 5-second tick; override with Self::receiver_queue_adjust_interval.

Source

pub fn receiver_queue_adjust_interval(self, interval: Duration) -> Self

Override the auto-adjust tick cadence for Self::receiver_queue_policy.

Source

pub fn initial_position(self, position: InitialPosition) -> Self

Initial position for every per-partition child consumer.

Source

pub fn durable(self, durable: bool) -> Self

Toggle durability of the underlying subscriptions.

Source

pub fn priority_level(self, level: i32) -> Self

Mirrors ConsumerBuilder::priority_level.

Source

pub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self

Mirrors ConsumerBuilder::property.

Source

pub fn subscription_property( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Mirrors ConsumerBuilder::subscription_property.

Source

pub fn read_compacted(self, on: bool) -> Self

Mirrors ConsumerBuilder::read_compacted.

Source

pub fn negative_ack_redelivery_delay(self, delay: Duration) -> Self

Mirrors ConsumerBuilder::negative_ack_redelivery_delay.

Source

pub fn ack_timeout(self, timeout: Duration) -> Self

Mirrors ConsumerBuilder::ack_timeout.

Source

pub fn ack_group_time(self, window: Duration) -> Self

Mirrors ConsumerBuilder::ack_group_time. Applied to every per-partition child.

Source

pub fn dead_letter_policy( self, max_redeliver_count: u32, dead_letter_topic: Option<String>, ) -> Self

Mirrors ConsumerBuilder::dead_letter_policy.

Source

pub fn max_pending_chunked_message(self, max: usize) -> Self

Mirrors ConsumerBuilder::max_pending_chunked_message.

Source

pub fn auto_ack_oldest_chunked_message_on_queue_full( self, auto_ack: bool, ) -> Self

Mirrors ConsumerBuilder::auto_ack_oldest_chunked_message_on_queue_full.

Source

pub fn expire_time_of_incomplete_chunked_message(self, expire: Duration) -> Self

Mirrors ConsumerBuilder::expire_time_of_incomplete_chunked_message.

Source

pub fn key_shared_policy(self, cfg: KeySharedConfig) -> Self

Mirrors ConsumerBuilder::key_shared_policy.

Source

pub fn replicate_subscription_state(self, on: bool) -> Self

Mirrors ConsumerBuilder::replicate_subscription_state.

Source

pub fn force_topic_creation(self, on: bool) -> Self

Mirrors ConsumerBuilder::force_topic_creation.

Source

pub fn start_message_rollback_duration(self, seconds: u64) -> Self

Mirrors ConsumerBuilder::start_message_rollback_duration.

Source

pub fn auto_update_partitions_interval(self, interval: Duration) -> Self

Enable a background timer that signals every interval, intended to drive re-checks of the topic’s partition count. Mirrors Java ConsumerBuilder#autoUpdatePartitionsInterval.

The internal timer task signals PartitionedConsumer::partitions_changed_notify on every tick. Callers run PartitionedConsumer::refresh_partitions in response to the signal (or on their own cadence) to actually call PulsarClient::partitions_for_topic.

Default None — no timer is spawned. Pass a non-zero Duration to opt in. The timer is aborted when the PartitionedConsumer (and every clone) is dropped.

Setting a zero interval is treated as “disable” — same as the default.

Source§

impl<E> PartitionedConsumerBuilder<'_, E>

Source

pub async fn subscribe( self, ) -> Result<PartitionedConsumer<<E::ClientState as SubscribeApi>::Consumer>, PulsarError>

Query partition count, then open one per-partition consumer. If the broker reports 0 partitions the builder falls back to a single consumer on the original topic.

Source§

impl<E> PartitionedConsumerBuilder<'_, E>

Source

pub async fn subscribe_with_listener( self, ) -> Result<MessageListenerHandle, PulsarError>

Query the partition count, open one consumer per partition, and start a push-delivery poller over the resulting PartitionedConsumer, returning the owning crate::MessageListenerHandle. Mirrors Java’s ConsumerBuilder#messageListener(...) + subscribe() against a partitioned topic.

Same semantics as crate::MultiTopicsConsumerBuilder::subscribe_with_listener: sequential, in-order delivery across every partition, no auto-ack (the callback acks via the topic-routed PartitionedConsumer::ack), clean shutdown on consumer-set drain / handle drop.

§Errors

Trait Implementations§

Source§

impl<E: Engine> Debug for PartitionedConsumerBuilder<'_, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, E = TokioEngine> !RefUnwindSafe for PartitionedConsumerBuilder<'a, E>

§

impl<'a, E = TokioEngine> !UnwindSafe for PartitionedConsumerBuilder<'a, E>

§

impl<'a, E> Freeze for PartitionedConsumerBuilder<'a, E>
where &'a PulsarClient<E>: Freeze,

§

impl<'a, E> Send for PartitionedConsumerBuilder<'a, E>
where &'a PulsarClient<E>: Send,

§

impl<'a, E> Sync for PartitionedConsumerBuilder<'a, E>
where &'a PulsarClient<E>: Sync,

§

impl<'a, E> Unpin for PartitionedConsumerBuilder<'a, E>
where &'a PulsarClient<E>: Unpin,

§

impl<'a, E> UnsafeUnpin for PartitionedConsumerBuilder<'a, E>
where &'a PulsarClient<E>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more