Design Pattern: MQTT Messaging

Problem Statement

Instances of the PUBLISH/SUBSCRIBE function block (FB) types implement the Interoperability provisions of the Compliance Profile to provide efficient data transfer over Local Area Networks via the User Datagram Protocol (UDP). This approach has the following drawbacks:

  1. Message delivery is only on a "best-efforts" basis. While this is usually sufficient over a single-hop LAN, delivery is likely to be delayed or to fail in a multi-hop system such as a mesh WiFi network or a Wide-Area Network (WAN), where Internet Protocol (IP) routing must be used.
  2. Care must be taken in the assignment of host IP addresses and port numbers to avoid accidental allocation of inconsistent data to the same PUBLISH/SUBSCRIBE channel. Within the context of a single System configuration, this error can be avoided by the use of the Tagged Data design pattern; however, conflicts may arise when multiple System configurations are operating on the same communications link.
  3. Additional care must be taken to avoid conflicts with other protocols that may be using UDP over the same UDP host/port allocation.

These drawbacks can be overcome by combining the Tagged Data design pattern with MQTT messaging at a Quality of Service (Qos) value of 2, i.e., guaranteed and acknowledged delivery of a single copy of each published multicast message on a given topic to all subscribers of that topic.

Framework

Tool Support

Tagged Data

Methodology

MQTT_TEST, MQTT_TAGS

MQTT_STATS, UDP_STATS