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>
impl<'a, S: Schema, E: Engine> TypedConsumerBuilder<'a, S, E>
Sourcepub fn message_listener(self, listener: TypedMessageListener<S>) -> Self
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).
Sourcepub fn name(self, name: impl Into<String>) -> Self
pub fn name(self, name: impl Into<String>) -> Self
Set the consumer name advertised to the broker. Mirrors Java
ConsumerBuilder#consumerName.
Sourcepub fn priority_level(self, level: i32) -> Self
pub fn priority_level(self, level: i32) -> Self
Mirrors ConsumerBuilder::priority_level.
Sourcepub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn property(self, key: impl Into<String>, value: impl Into<String>) -> Self
Mirrors ConsumerBuilder::property.
Sourcepub fn subscription_property(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn subscription_property( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Mirrors ConsumerBuilder::subscription_property.
Sourcepub fn read_compacted(self, on: bool) -> Self
pub fn read_compacted(self, on: bool) -> Self
Mirrors ConsumerBuilder::read_compacted.
Sourcepub fn negative_ack_redelivery_delay(self, delay: Duration) -> Self
pub fn negative_ack_redelivery_delay(self, delay: Duration) -> Self
Mirrors ConsumerBuilder::negative_ack_redelivery_delay.
Sourcepub fn ack_timeout(self, timeout: Duration) -> Self
pub fn ack_timeout(self, timeout: Duration) -> Self
Mirrors ConsumerBuilder::ack_timeout.
Sourcepub fn ack_group_time(self, window: Duration) -> Self
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.
Sourcepub fn dead_letter_policy(
self,
max_redeliver_count: u32,
dead_letter_topic: Option<String>,
) -> Self
pub fn dead_letter_policy( self, max_redeliver_count: u32, dead_letter_topic: Option<String>, ) -> Self
Mirrors ConsumerBuilder::dead_letter_policy.
Sourcepub fn max_pending_chunked_message(self, max: usize) -> Self
pub fn max_pending_chunked_message(self, max: usize) -> Self
Mirrors ConsumerBuilder::max_pending_chunked_message.
Sourcepub fn auto_ack_oldest_chunked_message_on_queue_full(
self,
auto_ack: bool,
) -> Self
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.
Sourcepub fn expire_time_of_incomplete_chunked_message(self, expire: Duration) -> Self
pub fn expire_time_of_incomplete_chunked_message(self, expire: Duration) -> Self
Mirrors ConsumerBuilder::expire_time_of_incomplete_chunked_message.
Mirrors ConsumerBuilder::key_shared_policy. Only meaningful with Key_Shared
subscription type.
Sourcepub fn start_message_id(self, id: MessageId) -> Self
pub fn start_message_id(self, id: MessageId) -> Self
Mirrors ConsumerBuilder::start_message_id. Only honoured for fresh subscriptions.
Sourcepub fn replicate_subscription_state(self, on: bool) -> Self
pub fn replicate_subscription_state(self, on: bool) -> Self
Mirrors ConsumerBuilder::replicate_subscription_state.
Sourcepub fn force_topic_creation(self, on: bool) -> Self
pub fn force_topic_creation(self, on: bool) -> Self
Mirrors ConsumerBuilder::force_topic_creation.
Sourcepub fn start_message_rollback_duration(self, seconds: u64) -> Self
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.
Sourcepub fn subscription(self, name: impl Into<String>) -> Self
pub fn subscription(self, name: impl Into<String>) -> Self
Required: set the subscription name.
Sourcepub fn subscription_type(self, sub_type: SubType) -> Self
pub fn subscription_type(self, sub_type: SubType) -> Self
Set the subscription type.
Sourcepub fn initial_position(self, position: InitialPosition) -> Self
pub fn initial_position(self, position: InitialPosition) -> Self
Set the initial position the broker dispatches from when the subscription is new.
Sourcepub fn receiver_queue_size(self, size: usize) -> Self
pub fn receiver_queue_size(self, size: usize) -> Self
Set the receiver queue size.
Source§impl<S: Schema, E: Engine> TypedConsumerBuilder<'_, S, E>where
E::ClientState: SubscribeApi,
impl<S: Schema, E: Engine> TypedConsumerBuilder<'_, S, E>where
E::ClientState: SubscribeApi,
Sourcepub async fn subscribe(
self,
) -> Result<TypedConsumer<S, <E::ClientState as SubscribeApi>::Consumer>, PulsarError>
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>
impl<S: Schema + Send + Sync + 'static, E: Engine> TypedConsumerBuilder<'_, S, E>
Sourcepub async fn subscribe_with_listener(
self,
) -> Result<MessageListenerHandle, PulsarError>
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
PulsarError::Configif no listener was set viaSelf::message_listener.PulsarError::Clientif the one-shot broker schema resolution fails.PulsarError::Other(stringified) on broker rejection or wire failure.