Skip to content

Commit

Permalink
fix: Use nondurable cursors for pulsar readers (#324)
Browse files Browse the repository at this point in the history
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()`.
  • Loading branch information
omegaphoenix authored Aug 23, 2024
1 parent 5bb283a commit a4012e8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/consumer/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ impl<Exe: Executor> ConsumerBuilder<Exe> {
// would this clone() consume too much memory?
let (mut config, mut joined_topics) = self.clone().validate::<T>().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.");
Expand Down

0 comments on commit a4012e8

Please sign in to comment.