How-To Guides
Integration Guides
Generic MQTT Integration Guide (Last Will and Testament)
5min
review the following guide for setting up an integration between manufacturing connect edge and an mqtt broker using last will and testament overview of mqtt last will and testament when this type of integration is set up, it includes a notification to other clients that are connected to the mqtt broker when your connection as a client disconnects when a client connects to the mqtt broker, it creates a connect packet that is predefined and sent to the mqtt broker you can define the message to notify you if the client disconnects there are four properties that you can set for the last will and testament lwt topic this is the topic that is used by the mqtt broker to send if the client disconnects lwt payload this is the payload message that is sent if the client disconnects qos this is the quality of service level (0, 1, or 2) retain this indicates if the message should be retained (true or false) the mqtt broker sends this message in the following scenarios if the client fails to communicate within the defined keep alive period if the client does not send a disconnect packet before it closes the network connection the broker closes the network connection due to a protocol error by the client step 1 add generic mqtt connector follow the steps to add a connector docid\ m2nifnaadyphcvzwmcoto and select the mqtt generic provider configure the following parameters name a recognizable name to identify the connector hostname enter the server address port confirm that the default value 1883 is entered client id enter the client id username (optional) password (optional) qos the quality of service (qos) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message select one of the following 0 the message is sent once and delivery isn’t guaranteed 1 this method guarantees that the message will be delivered to the broker, but also doesn’t prevent it being received multiple times 2 this method guarantees that the message will be delivered to the broker, and the message will be sent exactly once parallel publish count the number of messages being published simultaneously once the defined limit has been reached, subsequent messages are silently dropped the default value is 100 integration topic enter testtopic lwt topic enter lwttopicname lwt payload enter some lwt payload lwt payload type the payload type for mqtt's last will and testament feature the options are string and base64 lwt qos the quality of service value for mqtt's last will and testament feature lwt retained select this check box to retain the value for mqtt's last will and testament feature throttling limit the maximum number of messages per second to be processed the default value is zero, which means that there is no limit persistent storage when enabled, this will cause messages to undergo a store and forward procedure messages will be stored within manufacturing connect edge when cloud providers are online queue mode select the queue mode as lifo (last in first out) or fifo (first in first out) selecting lifo means that the last data entry is processed first, and selecting fifo means the first data entry is processed first step 2 enable the connector after adding the connector, click the toggle in the connector tile to enable it if you see a failed status, you can review the manage connectors docid\ zz28hztqbk7od xsj81o8 and relevant error messages step 3 verify connection in flows manager you can verify the connection is successfully set up by creating a flow in manufacturing connect edge to create a flow in manufacturing connect edge, navigate to flows manager click add flow enter mqtt lwt in the name field and click create flow click the start icon next to the mqtt lwt flow click the go to flow definition icon the flow canvas opens in a new browser tab from the node palette, drag the mqtt in node (network section) to the canvas double click the mqtt in node the edit mqtt in node dialog box appears click the edit icon next to the server field the add new mqtt broker config node dialog box appears in the name field, enter the name of the broker from the connection tab, configure the following parameters server enter the server address port enter 1883 client id enter the client id keep alive enter 60 click add from the edit mqtt in node dialog box, enter lwttopicname in the topic field select the desired qos value click done from the node palette, drag the debug node to the canvas and connect the two nodes click deploy expand the message window beneath the flow and click the debug icon verify that messages are displaying