File-based MQTT emulation
This communication package emulates a function of an MQTT broker by storing the messages in form of files in directories of a file system.
See Using communication packages for instructions on how to select the communication package, and configure it.
The file-based MQTT emulation is in the MQTT client role only.
The type name of the message channel object is: OpcLabs.BaseLib.Communication.Mqtt.FileMqttMessageChannel,OpcLabs.BaseLib .
The communicate package stores messages in files. The files are are organized in directories under the specified "root". The names of directories under the "root" and their structure correspond to the names and structure of MQTT topics.
The file naming scheme is such that the message order corresponds to the order of the file names. The file name includes a "tick" when the message channel started, and a sequential message number. This approach preserves the correct message order even if the application is restarted. The naming scheme is suitable for not more than one application publishing to any topic. If more applications publish to the same topic, the file name order will no longer correspond to message order.
Currently, only message publishing is supported. Subscribing to topics is not yet implemented.
Opening the channel
URL string
When the UseInputUrlString is 'false' (the default), the URL string, if provided by the host software, is ignored.
When the UseInputUrlString is 'true', the URL string must have the "file:" scheme, and is interpreted as the physical root directory.
Interface name
The interface name, if provided by the host software, is ignored.
Configuration
The table below lists the available properties, their types, and descriptions.
Property | Type | Description |
---|---|---|
ClearRootDirectory | System.Boolean | Determines whether the root directory will be cleared (recursively) when the message channel starts. Default is 'false'. |
CreatePhysicalRootDirectory | System.Boolean | Determines whether the physical root directory will be created automatically (if it does not exist) when the message channel starts. Default is 'true'. |
PhysicalFileProviderRoot | System.String | The directory path in the physical file system where the root topic will reside. Default is "/MqttRoot". The value form this property is only used when the UseInputUrlString is 'false' (the default). |
UseInputUrlString | System.Boolean | Determines whether the URL string provided by the host, which must have the "file:" scheme, will be interpreted as the physical root directory. Default is 'false'. |
Example
You can instruct the UADemoPublisher utility to produce JSON messages for MQTT and store them into a directory/file structure under "C:\MqttRoot" using the following command:
publish --MqttJsonTcp --ConnectionProperty {http://opclabs.com/OpcUA/PubSub}MessageChannel!=[String]OpcLabs.BaseLib.Communication.Mqtt.FileMqttMessageChannel,OpcLabs.BaseLib