Example for using the pulsar-rs crate to read from a topic
This example also includes reconnect logic to get around a known bug in the Pulsar broker where recovering offloaded data from S3 sometimes causes fetching the next message to hang indefinitely. The reconnect code can be removed if you aren't experiencing this bug in your broker.
cp config.sample.toml config.toml
- Fill in the pulsar hostname, port, tenant, namespace, topic, and token in the
config.toml
RUST_LOG=info cargo run
- Note that the
cargo run
will hang indefinitely in case more messages are sent to the Pulsar topic - Data will be written to
data/{topic_name}.jsonl