Link Search Menu Expand Document Edit GitHub


The publish with a context works almost the same as Publish but it will not create a new connection and publish with a new client. Instead it uses the currently active context client.


client@host> pub    -t <topics> [-t <topics>]... 
                    (-m <message> | -m:file <filename> | -m:empty)
                    [-q <qos>]... 
                    [-e <messageExpiryInterval>] 
                    [-cd <correlationData>]                  
                    [-ct <contentType>]
                    [-pf <payloadFormatIndicator>]
                    [-rt <responseTopic>]
                    [-up <userProperties>]...


OptionLong VersionExplanationDefault
-t--topicThe MQTT topic where the message will be published. 
-m--messageThe message which will be published on the topic. 
-m:file--message-fileThe file whose payload will be published on the topic. 
-m:empty--message-emptySets the message to an empty payload. 
-q--qosUse a defined quality of service level on all topics if only one QoS is specified.
You can define a specific QoS level for every topic. The corresponding QoS levels will be matched in order to the given topics.
-r--retainMessage will be retained.false
-e--messageExpiryIntervalThe lifetime of the publish message in seconds. 
-cd--correlationDataThe correlation data of the publish message. 
-ct--contentTypeA description of the content of the publish message. 
-pf--payloadFormatIndicatorThe payload format indicator of the publish message. 
-rt--responseTopicThe topic name for the response message of the publish message. 
-up--userPropertyA user property of the publish message. 


Publish with a client identified with myClient to the default settings:

mqtt> con -i myClient
myClient@localhost> pub -t test -m msg