Hacker News new | ask | show | jobs
by Groxx 4393 days ago
How do you know if you can handle the message, until you read the message? Or is MQTT's flow control inherently insufficient for cases like that?

Basic example, say for a chat client: to ensure delivery, you probably want to read the message, save it to a database, then confirm receipt. Is that possible, or would that delayed-ack have to be done via some other means?

1 comments

That's the normal use case for QoS 1 and 2 messages: the client must acknowledge each received message otherwise the server will try to resend it. From the MQTT V3.1 Protocol Spec: http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mq...

What you don't want to do is read everything offered into memory faster than you can write it to disk / database. You could potentially fill the memory until you run out and crash. Instead control the flow by not reading until you are finished with the previous message (or better, allow N unacknowledged messages to be read, where N is just enough so that the application is as fast as it can be).