pulsar-rs icon indicating copy to clipboard operation
pulsar-rs copied to clipboard

Connection Loss During Consumer Poll

Open cameronpickham opened this issue 3 years ago • 3 comments

If a consumer's connection becomes unusable while it is polling for new messages, how is this handled? Should there be a seamless reconnect? Does it use the same connection retry options that are used when the initial connection attempt fails?

cameronpickham avatar Apr 22 '21 20:04 cameronpickham

It seems there are reconnect operations both when creating a consumer in TopicConsumer::new and consuming messages after ConsumerEngine started , but there's no retry when consuming messages, if reconnect fails in engine, the loop in engine method will stop.

wexgjduv avatar Apr 24 '21 00:04 wexgjduv

FYI I'm in the process of fixing issues around that, the next version should be more stable

Geal avatar May 14 '21 09:05 Geal

As a workaround, I've used this:

info!("Starting the consumer loop");
loop {
    let mut consumer = libpulsar::new_consumer::<VideoEvent>(&pulsar_conn, &topic).await?;
    info!("Consumer started");
    let e = consumer_loop(consumer).await;
    warn!("Consumer was closed because of {:?}, restarting it...", e);
}

whisust avatar Dec 02 '21 11:12 whisust