Video Tutorial: Using DataHub Advanced MQTT Parsing

4 min read

Aug 25, 2022 2:00:00 PM

Cogent DataHub® is a gateway that enables a wide range of connectivity interfaces for different data sources such as OPC UA, OPC DA, ODBC, DDE and so much more.  Included in those available interfaces is the ability to act as both an MQTT client and broker even including Sparkplug B support for enabling MQTT integration with many other types of systems that don't natively support MQTT.

A key facet of the MQTT specification that can sometimes be complex for our users and cause issues with compatibility between DataHub and other MQTT clients and brokers is how to handle the formatting of MQTT messages. As you may or may not know, while MQTT does specify how to construct a message header for routing by an MQTT broker, it does NOT specify the actual message content. This tends to be a challenge when MQTT clients from different developers need to work together, since they need to be using the same format for the message content.

In this video blog, I'll show you how to use DataHub V10's Advanced MQTT Parser capability to specify flexible formats that will work with virtually any other vendor's MQTT clients and brokers.

Watch this video to learn how to use the Advanced JSON Message Format Parser with the Cogent DataHub MQTT broker and/or client plug-ins including basic setup, which is key to interoperability between DataHub and other MQTT clients and brokers by enabling virtually any MQTT message format. For users of MQTT Sparkplug B, which actually does define a common message format, DataHub client and broker do support Sparkplug B - click here for details.

Looking for other how-to videos for DataHub?  Click here!



Just to summarize, in this video, I've shown you how to use the JSON Advanced Message Formatter, specifically including:

  1. Adding a new JSON Schema
    1. Adding a Sample Input "payload" (i.e. the format of a raw JSON message being sent to or received from an MQTT broker).
    2. Generating a JSON Schema format from the Sample Input payload (which should generally be easy to access from any other MQTT client or broker). A "schema" is basically a framework that defines the variables in a payload and their associated properties.
    3. Examples of when it might be appropriate to alter the generated schema.
  2. Testing and editing the output / tags that will be generated by a schema
    1. How to exclude paths from the test output to avoid adding undesired tags from an MQTT payload.
    2. How to modify the tags names for the output to be more descriptive including using other information from the MQTT packet as part of the tag name and even removing parts of a JSON path that should not be included.
    3. How to use the timestamp included in an MQTT packet (where applicable) as the timestamp for the output tags in DataHub.
  3. Defining the data from the MQTT packet that will be output to the defined tags
    1. How to source the value, quality and timestamp information such that the defined tags are compatible with other interfaces such as OPC.
    2. How to convert from JSON date/time to a Date/Time format (there are other methods for converting other time formats including UNIX time). This is important because other interfaces/systems won't recognize JSON time formatting.
    3. Testing the output to confirm that the tag names and their data match the expected output.
  4. Creating templates from schemas for future use
  5. Testing advanced MQTT schemas using an external MQTT test client connecting to DataHub

(NOTE: While this video specifically steps through configuration with the DataHub MQTT Broker, the same formatting support applies for DataHub MQTT Client configurations, as well)

Additionally, this video was focused on the advanced message formatting capabilities included with DataHub V10 - for details on configuring MQTT connectivity beyond the message formatting in more detail, the following additional video resources will be useful:

Don't forget to subscribe to our blog to find out about the latest updates to DataHub and for future how-to videos on using DataHub.

Ready to use DataHub to integrate your own MQTT clients and brokers?

Get started integrating your own MQTT clients and brokers with DataHub free trial

Win Worrall
Written by Win Worrall

Software Toolbox Technical Blog

We're engineers like you, so this blog focuses on "How to" appnotes, videos, tech team tips, product update announcements, user case studies, and other technical updates.  Subscribe to updates below. Your feedback and questions on posts are always welcomed - just use the area at the bottom of any post.

Subscribe to our Blog

Recent Posts

Posts by Topic

See all