Publish a message

Private Sub Publish() On Error GoTo errExit Dim retCode As MqttPublishCode Dim msg As MQTTMessage Dim data() As Byte Set msg = mFactory.CreateApplicationMessage() msg.PayloadFormat = MqttPayloadCharacter msg.Topic = "SE" msg.payload = "This is the payload." msg.QoS = MqttQoS2 ' Configure more advanced MQTT properties, which are not necessary configurations. Configure them as needed. msg.SubscriptionIdentifiers = CLng(5) msg.contenttype = "String" data = StrConv("This is the correlation data.", vbFromUnicode) msg.correlation = data msg.ResponseTopic = "This is the response topic." msg.AddUserProperty "Key1", "Value1" msg.AddUserProperty "Key2", "Value2" retCode = mClient.Publish(msg) Exit Sub errExit: MsgBox err.Description End Sub
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal