rumqtt icon indicating copy to clipboard operation
rumqtt copied to clipboard

Disable auto acks

Open tekjar opened this issue 5 years ago • 3 comments

#94

Sometimes users might want to send acks after handling incoming publishes. Add compile time feature to disable auto acks and provide method to send ack

tekjar avatar Oct 31 '18 11:10 tekjar

I have a suggestion how to fix the "auto acks" problem. I suggest to extent the enum Notification:: Publish(Publish) with information needed for confirming a received message. => enum Notification:: Publish(Publish,AckInfo) and not, as now, confirming incoming message immediately. After the Notification:: Publish(Publish,AckInfo) was processed in the user code, Rust calls drop() method for the AckInfo struct. Within this method should the acknowledgement be sent to the Brocker. For this AckInfo must implement the Dorp Traid. This is only the rough approach to solve this problem. I'm too new in rust to fix the problem myself.

stanmueller avatar Feb 20 '19 19:02 stanmueller

@stanmueller Sounds reasonable to me. This AckInfo would contain a oneshot::Sender.

Another thing that comes to my mind is a ordinary Stream instead of the crossbeam channel - but this would be a complete different API. e.g

fn subscribe(topic, qos, consumer: impl Stream<Item = Publish, Error = io::Error>) -> Result<..>

if you're lazy you can just pass a channel tx half.

flxo avatar Feb 20 '19 19:02 flxo

@stanmueller Yeah that sounds plausible. But I should say that disabling auto-ack isn't a priority for me now. Will come back to this after next release. But you are welcome to give it a shot now :). I would be interested in how it looks

tekjar avatar Feb 25 '19 08:02 tekjar