amqp-rs / lapin

AMQP client library in Rust, with a clean, futures based API
MIT License
1.04k stars 92 forks source link

tokio.rs example doesn't work correctly #384

Closed eliaseinarsson closed 1 year ago

eliaseinarsson commented 1 year ago

The example in examples/tokio.rs doesn't seem to function correctly. Using the latest version of Lapin and RabbitMQ (2.3.1 and 3.12.2 respectively) the example exits as soon as the queue is empty.

As I'm fairly new to Rust, I'm unsure what the issue is exactly, but the intended functionality of the example is presumably - the same as in the other examples - for the process to wait for more messages to enter the queue and consume those as well. Since there is no documentation for set_delegate() I'm unsure whether this is expected behavior and you have to add something to the example to get it to wait for more messages, or if it's supposed to function how I'm describing and this is just a bug.

dennohpeter commented 1 year ago

All am also experiencing the same, any solutions @eliaseinarsson

Keruspe commented 1 year ago

Adding a future::pending().await in the end so that it runs indefinitely should do the tricks. They're more like code snippets, they're not exactly meant to be ran as is