Product Documentation

MQTT V3 Plug-in Reference

Previous Topic

Next Topic

Example of a Configuration Message

Below is a real-world example of a JSON document in the payload of a configuration message published with the topic of "ctreeAdministration" to the FairCom MQTT Broker.

This JSON document configures the FairCom MQTT Broker to create a Persistence Topic called "AirInfo", which in turn creates a table called "AirInfo" that contains the fields "airSensorID", "airTemp", "airHumidity", "airPressure", "airQuality", "correctionFactor", "sensorGroup", "lastAlertDate", and "lastAlertTime", and a field to hold an image, "image1".

It also creates a message handler that listens to messages published with the Persistence Topic of "AirInfo". The message handler extracts the payload of these messages, which is a JSON document containing the properties "sensorID", "temperature", "humidity", "pressure", "quality", "correction", "group", "lastAlertDate", and "lastAlertTime", and the image "image1".

The message handler extracts data values from each JSON document, maps them to fields, and inserts a record into the "AirInfo" table in the c-tree database.

Records in this table are retained for 10 days.

The default JSON date format is changed from "CCYY.MM.DD" to "CCYYMMDD". This causes the message handler to interpret a date embedded in a JSON string using the pattern, "20190101" instead of the default of "2019/01/01".

{

"operation": "CreatePersistenceTopic",

"persistenceTopic": "AirInfo",

"tableName": "AirInfo",

"tableRetentionPeriod": 10,

"tableRetentionUnit": "day",

"defaultDateFormat": "CCYYMMDD",

"defaultTimeFormat": "hh.mm.am/pm",

"mapOfPropertiesToFields": [

{

"propertyPath": "sensorID",

"fieldName": "airSensorID",

"fieldType": "CHAR",

"fieldWidth": 15

},

{

"propertyPath": "temperature",

"fieldName": "airTemp",

"fieldType": "NUMBER",

"fieldScale": 6

},

{

"propertyPath": "humidity",

"fieldName": "airHumidity",

"fieldType": "REAL"

},

{

"propertyPath": "pressure",

"fieldName": "airPressure",

"fieldType": "INTEGER"

},

{

"propertyPath": "quality",

"fieldName": "airQuality",

"fieldType": "BIGINT"

},

{

"propertyPath": "correction",

"fieldName": "correctionFactor",

"fieldType": "DOUBLE"

},

{

"propertyPath": "group",

"fieldName": "sensorGroup",

"fieldType": "SMALLINT"

},

{

"propertyPath": "lastAlertDate",

"fieldName": "lastAlertDate",

"fieldType": "DATE"

},

{

"propertyPath": "lastAlertTime",

"fieldName": "lastAlertTime",

"fieldType": "TIME"

},

{

"propertyPath": "image1",

"fieldName": "image1",

"fieldType": "LVARBINARY"

}

]

}

TOCIndex