Skip to main content

TypedConsumerBuilder

Struct TypedConsumerBuilder 

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

Builder for a TypedConsumer.

Generic over E: Engine (ADR-0026 §D1). The default (E = crate::TokioEngine) keeps existing callers source-compatible. Moonpool callers parametrise with TypedConsumerBuilder<'_, S, MoonpoolEngine<P>> and get a TypedConsumer<S, magnetar_runtime_moonpool::Consumer<P>> from Self::subscribe.

Implementations§

Source§

impl<'a, S: Schema, E: Engine> TypedConsumerBuilder<'a, S, E>

Source

pub fn message_listener(self, listener: TypedMessageListener<S>) -> Self

Register a schema-aware push-delivery callback (Java ConsumerBuilder<T>#messageListener). Once set, subscribe via Self::subscribe_with_listener to start a background poller that decodes each message and hands the TypedMessage to listener, sequentially and in order. The plain Self::subscribe ignores the listener and returns a pull-mode TypedConsumer.

The callback must ack explicitly — the poller never auto-acks (Java parity).

Source

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

Set the consumer name advertised to the broker. Mirrors Java ConsumerBuilder#consumerName.

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. Coalesces fire-and-forget acks emitted via TypedConsumer::ack_grouped / TypedConsumer::ack_grouped_cumulative.

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. Only meaningful with Key_Shared subscription type.

Source

pub fn start_message_id(self, id: MessageId) -> Self

Mirrors ConsumerBuilder::start_message_id. Only honoured for fresh subscriptions.

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. Rolls the subscription cursor back by seconds at subscribe time.

Source

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

Required: set the subscription name.

Source

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

Set the subscription type.

Source

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

Toggle durability.

Source

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

Set the initial position the broker dispatches from when the subscription is new.

Source

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

Set the receiver queue size.

Source§

impl<S: Schema, E: Engine> TypedConsumerBuilder<'_, S, E>

Source

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

Build and subscribe via the engine-generic crate::SubscribeApi trait. The configured schema is advertised on CommandSubscribe.schema.

Source§

impl<S: Schema + Send + Sync + 'static, E: Engine> TypedConsumerBuilder<'_, S, E>

Source

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

Subscribe and start a schema-aware push-delivery poller, returning the owning crate::MessageListenerHandle. Mirrors Java’s ConsumerBuilder<T>#messageListener(...) + subscribe().

Each message is decoded against the configured schema and the resulting TypedMessage is handed to the callback sequentially and in order. The poller does not auto-ack (the callback acks explicitly) and stops cleanly when the consumer is closed or the returned handle is dropped.

If the schema needs a broker-side resolution (Schema::needs_broker_schema), it is resolved once before the poller starts, so per-message decoding in the callback stays synchronous.

§Errors

Trait Implementations§

Source§

impl<S: Schema, E: Engine> Debug for TypedConsumerBuilder<'_, S, E>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

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

§

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

§

impl<'a, S, E> Freeze for TypedConsumerBuilder<'a, S, E>
where &'a PulsarClient<E>: Freeze, Arc<S>: Freeze, Option<Arc<dyn Fn(&TypedMessage<S>) + Send + Sync>>: Freeze,

§

impl<'a, S, E> Send for TypedConsumerBuilder<'a, S, E>
where &'a PulsarClient<E>: Send, Arc<S>: Send, Option<Arc<dyn Fn(&TypedMessage<S>) + Send + Sync>>: Send,

§

impl<'a, S, E> Sync for TypedConsumerBuilder<'a, S, E>
where &'a PulsarClient<E>: Sync, Arc<S>: Sync, Option<Arc<dyn Fn(&TypedMessage<S>) + Send + Sync>>: Sync,

§

impl<'a, S, E> Unpin for TypedConsumerBuilder<'a, S, E>
where &'a PulsarClient<E>: Unpin, Arc<S>: Unpin, Option<Arc<dyn Fn(&TypedMessage<S>) + Send + Sync>>: Unpin,

§

impl<'a, S, E> UnsafeUnpin for TypedConsumerBuilder<'a, S, E>

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