From a4012e8156796190927ec79b7190efafff1a8dc0 Mon Sep 17 00:00:00 2001 From: Justin Leong Date: Thu, 22 Aug 2024 20:08:58 -0700 Subject: [PATCH] fix: Use nondurable cursors for pulsar readers (#324) By default we set subscriptions to use a durable cursor: https://github.com/streamnative/pulsar-rs/blob/master/PulsarApi.proto#L352 We only run into this when durable is None which can also be avoided if we use Pulsar::reader() which also sets durable to Some(false). However, there are cases where users may overwrite the options before calling `into_reader()`. --- src/consumer/builder.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/consumer/builder.rs b/src/consumer/builder.rs index 1f206ed6..3f9607da 100644 --- a/src/consumer/builder.rs +++ b/src/consumer/builder.rs @@ -324,6 +324,10 @@ impl ConsumerBuilder { // would this clone() consume too much memory? let (mut config, mut joined_topics) = self.clone().validate::().await?; + // Internally, the reader interface is implemented as a consumer using an exclusive, + // non-durable subscription + config.options.durable = Some(false); + // the validate() function defaults sub_type to SubType::Shared, // but a reader's subscription is exclusive warn!("Subscription Type for a reader is `Exclusive`. Resetting.");