In this post, I asked if it was possible to keep a message in a queue in ActiveMQ Artemis until all subscribers had received it, and the answer was that this can be done using the clean = false flag.
I haven't tested this yet due to corporate firewall restrictions, but I think the MQTT "clean" parameter may be handled in the Telegraf MQTT listener by the "persistent_session = true" parameter - there is no "clean" parameter available.
But I do wonder how MQTT distinguishes between when a particular subscriber is offline vs. when the subscriber process has simply been terminated? If you terminate the Telegraf process, it wouldn't be able to send the unsubscribe command, so the message would be kept permanently or until some message expiration limit has been met (that might be ok, actually).
So basically the question is, how do you specify the "clean" parameter in the Telegraf MQTT listener?
Different MQTT client implementations will represent protocol semantics in different ways. In this case it appears the Telegraf Input Plugin for MQTT represents the CleanSession
flag for the CONNECT
control packet as persistent_session
.
The documentation says this about persistent_session
:
## Persistent session disables clearing of the client session on connection.
## In order for this option to work you must also set client_id to identify
## the client. To receive messages that arrived while the client is offline,
## also set the qos option to 1 or 2 and don't forget to also set the QoS when
## publishing.
So setting persistent_session
to true
would seem to be equivalent to setting the CleanSession
flag to false
.