Link Search Menu Expand Document

NATS

Dec 6 2023 at 12:00 AM

  1. Introduction
  2. Example Options File
    1. Property Details
  3. Topic Parsing
  4. Configuration of the NATS data source node

Introduction

This data source is configured to subscribe to one or more topics on a NATS Server. The payload for each message published to the specified topic(s) will consist of the raw bytes received.

NATS topic paths support the use of wildcards:

  • Use ‘>’ to represent one or more subtopics (e.g., “telemetry/>”).
  • Use ‘*’ to represent one subtopic (e.g., “telemetry/*/temperature”).

Topic parsing is employed to set a Source Information key to a specific section of the topic.

Example Options File

{
  "Devices": {
    "Device1": {
      "DeviceType": "Generic",
      ...
      "DataSource": {
        "DataSourceType": "Nats",
        "Servers": [
          "nats://192.168.0.158:4222"
        ],
        "Topics": {
          "Telemetry": "natsTopic/liveTelemetry",
        }
      },
      ...
    }
  }  
}

Property Details


Here is an overview of the parameters for configuring the NATS data source:

Property NameDescription
DataSourceTypeSpecifies that the data source is of type “Nats.”
ServersThe list of NATS servers in the cluster.
TopicsA list of one or more Topic Names and their associated topics to subscribe to.
ParseTopicA list of string values determining which topic sections are stored in the Source Information. Refer to the section below.
PingIntervalThe interval, in milliseconds, that pings will be sent to the server. If set to 0, the default NATS client value is used
SecureSpecifies whether a secure connection (TLS) should be made to NATS servers. Defaults to true.
TimeoutThe timeout, in milliseconds, when connecting to a NATS server. If set to 0, the default NATS client value is used.
UserThe username used when connecting to the NATS server when not included directly in the URLs.
PasswordThe password used when connecting to the NATS server when not included directly in the URLs.
TokenThe token used when connecting to the NATS server when not included directly in the URLs.
CertificatePathThe full path to the certificate file, with the shortcut “$data$” available to specify the current /Data folder.
CertificatePasswordThe password used to open the certificate file.
ReconnectDelayThe delay time, in milliseconds, after a disconnection before the client attempts to reconnect, defaulting to 5,000 milliseconds (5 seconds).

Topic Parsing

When one or more strings are included in the ParseTopic list, the data source will divide the topic path of the received message using ‘/’ as the delimiter. If a string in the ParseTopic list is not blank (“”), the corresponding section of the topic path will be loaded into the Source Information with the specified key. For instance, suppose the topic path is “mqtttopic/telemetry/ABC123/temperature”, and the ParseTopic list is configured as [ “”, “”, “DeviceName” ]. In this case, the following key value pair will be added to the Source Information:

“DeviceName” = “ABC123”

Configuration of the NATS data source node

Every device should include the Device Information, Data Source, and Filter nodes. To create a device, click the + icon located on the top-left side of the ‘Create Device’ screen as shown in Figure 1. This action opens a configuration window for the device. Within this screen, users can select and add the necessary nodes. To add a node, access the ‘Add Node’ window, as illustrated in Figure 2.

Generic Driver

Figure 1 - Create Device

The window below enables the user to add and configure a data source node.

Generic Driver

Figure 2 - Add Node

The NATS node consists of features to:

  1. Configure the node: Allows users to customize and adjust the settings of the selected node according to their requirements.
  2. Show nodes compatible with the selected node: Displays nodes that are compatible with the selected node, providing a streamlined view of related options.
  3. Bring up the help centre for the node: Directs users to the help centre for the selected node, offering detailed guidance and documentation.
  4. Copy icon: Permits users to duplicate the selected node, facilitating efficient replication of configurations.
  5. Delete the node: Enables users to remove the selected node from the configuration, allowing for adjustments and refining the setup.

Generic Driver

Figure 3 - Node Features

Upon selecting the configure button in Figure 3, the window for the NATS data source node is presented as illustrated in Figure 4. In this interface, users can input and edit relevant information to configure the NATS data source.

Generic Driver

Figure 4 - NATS data source node

These details clarify the functionality and significance of each parameter in the configuration of the NATS data source.

  1. Data Source Options: This feature enables users to establish the origin and method type of the data source.
    • Data source type
    • Configuration path
  2. Topics: Users post their routing key, and the system selects the topic based on that input. Parse topics are simplified representations of these topics.
  3. Ping Interval: Determines the frequency at which notifications should be sent.
  4. Secure Checkbox: A checkbox indicating whether the connection should be secured.

Continue reading