Stream Data to Broker

Follow the guide Add Module to Apis Hive, but this time select a module of type ApisUaPublisherBee from the Module type dropdown list.

  • After adding the module, select the new module named "UaPublisherBee" from the Solution Explorer.
  • First select type of communication:
    • File (is used for debugging purposer, information is written to a file for inspection of mesages)
    • MQTT (when using MQTT protocole to the broker)
    • AMQP (when using AMQP protocole to the broker)
  • Press Apply

When the protocole is selected several parameters need to be set, and these wil wary depending on the selectet brokertype.

Brokertype: File

  • Properties
    • Filename: This propery shall be the filename to use.

This is mainly used for debugguing purpose, to see the content of message itself. the only property here is to set the filename where the messages will be stored. There will be one line for each messages. The plugin will use 10 files to avoid ublimited filesize and use of diskspace. When a file get a serten limit it will create a new file with name XX_o up til XX_9

Brokertype: AMQP

  • Properties
    • AMQP Type: select the communication to use eiter Websocket or HTTPS syncronius or not.
    • AMQPMain Address: The microsoft Endpoint to Eventhub where all realtime data are sent.
    • AMQPBackFill Address: The endpoint to the backfil channel.
    • AMQP Connectiontype. Multiple,single, or transient. Defailt is multiple.

In addition to thes settings the property the Main EntityPath/Topic and BackFill EntityPath/Topic have to be filled out. It is possible to use the same parameters for both Main and Backfill properties, but then all data will be sent to same Eventhub.

Brokertype: MQTT

  • Properties
    • MQTTMain Address: addres to broker eg test.mosquitto.org
    • MQTTMain Port: port to use e.g. 1883
    • MQTTMain ClientId: A unique string (e.g. GUID)
    • MQTTMain User: A user defined by the broker.
    • MQTTMain Password: password to the broker.
    • MQTTMain CleanSession: (enabled or not)
    • MQTTMain Version (V3.1.1 or V5.0)
    • MQTTMain Transport (Tspserver without security, TcpSerberTLS with security/encryption)
    • MQTTMain Client certificate: full name of a certificat, if then broker needs this to verify the clent.
    • MQTTBacFill Address: addres to broker eg test.mosquitto.org
    • MQTTBacFill Port: port to use e.g. 1883
    • MQTTBacFill ClientId: A unique string (e.g. GUID)
    • MQTTBacFill User: A user defined by the broker.
    • MQTTBacFill Password: password to the broker.
    • MQTTBacFill CleanSession: (enabled or not)
    • MQTTBacFill Version (V3.1.1 or V5.0)
    • MQTTBacFill Transport (Tspserver without security, TcpSerberTLS with security/encryption)
    • MQTTBacFill Client certificate: full name of a certificat, if then broker needs this to verify the clent.

These properties define communication to both the primary and secondary broker. The primary broker always get the realtime messages while the secondary gets messages that are old when doing catchup or resending old messages the primary broker did not accept. In adition to these properties the properies Main EntityPath/Topic and BackFill EntityPath/Topic has to be set. Also check documentation for common properties that has to be defined.

When using MQTT to Microsoft IOT Hub you get a connectionstring from Microsoft. This has to be decodes to different parameters. See https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#using-the-mqtt-protocol-directly-as-a-device to get details.

The other parameters van be changed later.

To start publishing data we need to:

  • Add a Apis OpcUa module. This represent the data to be published.

  • Follow the guide Add Items to a Module (UaPublisher) and add item of type "Writer Group".

    • The property PublishInterval define how often a message is published.
    • MaxNetworkMessageSize define the maximum size a message can bee.
  • Follow the guide Add Items to a Module (UaPublisher) and add item of type "Variable Dataset Writer". This is used to connect the dataset to a "Writer Group".

    • Select the "Writer Group" in the WriterGroupItem property.
    • Select the ApisOpcUa module in property "DataSetName"

Now there should be a system that every PublisherInterval create a message including all data arrived in current interval, create a message according to the configuration, and send this to the Eventhub. To see how the transmitted messages look like select BrokerType equal to File and press Apply. Then enter a filname for property "FileName" (id 2300). Then published messages are written to that file. This is a nice way to verify that the messages look as expected. When satisfied then go back and send the messages to the eventhub.

One Publisher can have many "Writer Group" Items and "Variable Dataset Writer". A "Variable Dataset Writer" can only be connected to one Datset (Apis OpcUa module) and one "Writer Group". A Dataset can only be connected to one "Variable Dataset Writer".

To get an overview of the dataflow in a PublishertBee se figure in ApisUaPublisherBee.