.. include:: vars.rst .. _section-configuration: ************* Configuration ************* This section describes how to configure |RSMQTT|. All configuration is specified in |RS|'s XML configuration file. .. _section-how-to-load-plugin: Load the MQTT Adapter Plugin ============================ |RSMQTT| must be registered as a plugin on |RS| using the ```` tag. Once the dynamic library and constructor function have been registered, |RS| will create an instance of the plugin during start-up, and the plugin can be used to create one or more connections to an |MQTT_BROKER|. The following snippet demonstrates how to register the plugin in the ```` section of |RS|'s XML configuration: .. code-block:: xml rtimqttadapter RTI_RS_MQTT_AdapterPlugin_create .. warning:: |RS| must be able to find the |RSMQTT| dynamic library (|MQTT_ADAPTER_LIB_NAME_LINUX| on Linux® systems, |MQTT_ADAPTER_LIB_NAME_MAC| on macOS® systems, or |MQTT_ADAPTER_LIB_NAME_WIN| on Windows® systems). Make sure to include the library's directory in the library search path environment variable appropriate for your system (``LD_LIBRARY_PATH`` on Linux systems, ``RTI_LD_LIBRARY_PATH`` on macOS systems, ``PATH`` on Windows systems, etc.). .. _section-adapter-data-types: Register MQTT Data Types ======================== |RSMQTT| exposes data to |RS| using two possible |DDS_TYPES|: ``RTI::MQTT::Message`` and ``RTI::MQTT:KeyedMessage``. The IDL definition of these types is included with |RSMQTT|, and built in into the library, but it is necessary to register them in |RS|'s XML configuration to make it available outside of the adapter: .. code-block:: xml .. _section-adapter-qos: Configure QoS ============= The types used by |RSMQTT| make used of "unbounded" strings and sequences. The following QoS parameters must be configured in order to enable use of "unbounded" types: .. code-block:: xml true dds.data_reader.history.memory_manager.fast_pool.pool_buffer_max_size 10485760 dds.data_writer.history.memory_manager.fast_pool.pool_buffer_max_size 10485760 .. _section-how-to-config-connection: Connect to an |MQTT_BROKER| =========================== Once the plugin has been registered with |RS|, it can be used to create ```` elements within a ````. The ````'s configuration must include properties ``client.id``, and ``client.servers`` to configure the associated |MQTT_CLIENT|. The following snippet shows an example ```` that connects to a local |MQTT_BROKER|: .. code-block:: xml client.id mqtt_router client.servers tcp://127.0.0.1:1883 0 .. _section-how-to-route-mqtt-to-dds: Route Data from MQTT to DDS =========================== A ```` created by |RSMQTT| can be used to define ```` elements which will subscribe to |MQTT_MESSAGES| from the |MQTT_BROKER|, and expose them to the enclosing ```` as |DDS_SAMPLES| of either ``RTI::MQTT::Message``, or ``RTI::MQTT::KeyedMessage``. The specific |DDS_TYPE| to use is determined from the value of the ```` element. The |MQTT_CLIENT| associated with the ```` will be used to create subscriptions on the |MQTT_BROKER| for every topic filter specified in property ``subscription.topics``. The value of this property is a list of semicolon-separated |MQTT_TOPIC_FILTERS|. The following snippet demonstrate how to create an ```` which will subscribe to all topics available on the |MQTT_BROKER|, and route them to |DDS_TOPIC| ``"dds_mqtt"`` using |DDS_TYPE| ``RTI::MQTT:KeyedMessage``: .. code-block:: xml RTI::MQTT::KeyedMessage subscription.topics # RTI::MQTT::KeyedMessage .. warning:: While possible, it is discouraged to specify the same topic filter on multiple ```` elements belonging to the same ````. Each duplicated topic filter will result in a single subscription on the |MQTT_BROKER| with settings from the last ```` to be created. .. _section-how-to-route-dds-to_mqtt: Route Data from DDS to MQTT =========================== A ```` created by |RSMQTT| can be used to define ```` elements that will convert |DDS_SAMPLES| into |MQTT_MESSAGES|, and publish them to a topic on the ````'s |MQTT_BROKER|. |DDS_SAMPLES| must be of type ``RTI::MQTT::Message``, or ``RTI::MQTT::KeyedMessage``. The following snippet demonstrate how to configure an ```` to publish the payload of ``RTI::MQTT::KeyedMessage`` |DDS_SAMPLES| published on topic ``"dds_mqtt"`` to |MQTT_TOPIC| ``"foo/bar"``, with |MQTT_QOS| 1: .. code-block:: xml RTI::MQTT::KeyedMessage RTI::MQTT::KeyedMessage publication.topic foo/bar publication.qos 1 Alternatively, property ``publication.use_message_info`` be used to have the ```` use the metadata contained in published |DDS_SAMPLES| to determine other publication setttings (e.g. topic, qos, retained flags, etc.): .. code-block:: xml RTI::MQTT::KeyedMessage RTI::MQTT::KeyedMessage publication.use_message_info true .. _section-adapter-xml-properties: XML Configuration properties ============================ This section describes the properties that can be used to configure |RSMQTT|. .. _section-adapter-xml-properties-client: :litrep:`` Properties --------------------------------- Each ```` created by the |RSMQTT| plugin is associated with an |MQTT_CLIENT| which must be configured using the ```` tag. Most configuration properties have "reasonable" default values, except for ``client.id``, and ``client.servers`` which must be always specified. .. list-table:: :litrep:`` Properties :widths: 90 10 :header-rows: 1 * - Property - Required * - :ref:`section-adapter-xml-properties-client-id` - Yes * - :ref:`section-adapter-xml-properties-client-servers` - Yes * - :ref:`section-adapter-xml-properties-client-protocol` - No * - :ref:`section-adapter-xml-properties-client-conntimeout-sec` - No * - :ref:`section-adapter-xml-properties-client-conntimeout-nsec` - No * - :ref:`section-adapter-xml-properties-client-maxconnretries` - No * - :ref:`section-adapter-xml-properties-client-keepalive-sec` - No * - :ref:`section-adapter-xml-properties-client-keepalive-nsec` - No * - :ref:`section-adapter-xml-properties-client-clean` - No * - :ref:`section-adapter-xml-properties-client-unsub` - No * - :ref:`section-adapter-xml-properties-client-maxreply-sec` - No * - :ref:`section-adapter-xml-properties-client-maxreply-nsec` - No * - :ref:`section-adapter-xml-properties-client-reconnect` - No * - :ref:`section-adapter-xml-properties-client-maxunack` - No * - :ref:`section-adapter-xml-properties-client-persistence` - No * - :ref:`section-adapter-xml-properties-client-persistencestorage` - No * - :ref:`section-adapter-xml-properties-client-username` - No * - :ref:`section-adapter-xml-properties-client-password` - No * - :ref:`section-adapter-xml-properties-client-ssl-ca` - No * - :ref:`section-adapter-xml-properties-client-ssl-id` - No * - :ref:`section-adapter-xml-properties-client-ssl-key` - No * - :ref:`section-adapter-xml-properties-client-ssl-key-passwd` - No * - :ref:`section-adapter-xml-properties-client-ssl-proto` - No * - :ref:`section-adapter-xml-properties-client-ssl-verifycert` - No * - :ref:`section-adapter-xml-properties-client-ssl-cyphers` - No .. _section-adapter-xml-properties-client-id: client.id ^^^^^^^^^ :Required: Yes :Default: None :Description: The "client id" that will be sent to the |MQTT_BROKER| during connection. The value must be unique within all clients connected to the same |MQTT_BROKER|. :Accepted Values: Any non-empty alphanumeric string .. _section-adapter-xml-properties-client-servers: client.servers ^^^^^^^^^^^^^^ :Required: Yes :Default: None :Description: A list of |MQTT_BROKER| URIs to which the |MQTT_CLIENT| will try to connect, in the specified order, until a connection can be successfully established. :Accepted Values: A list of |MQTT_BROKER| URIs, separated by semicolon. Each URI takes the form ``://
:``, where ```` can be one of: - ``tcp``: connect to |MQTT_BROKER| using a TCP connection. - ``ssl``: connect to |MQTT_BROKER| using an SSL/TLS connection. .. note:: ``tcp://127.0.0.1:1883`` is usually the default URI to connect to an |MQTT_BROKER| deployed on your local machine (e.g. if you are using |MOSQUITTO|). .. _section-adapter-xml-properties-client-protocol: client.protocol_version ^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``default`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-conntimeout-sec: client.connection_timeout.sec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``10`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-conntimeout-nsec: client.connection_timeout.nanosec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``0`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-maxconnretries: client.max_connection_retries ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``10`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-keepalive-sec: client.keep_alive_period.sec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``10`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-keepalive-nsec: client.keep_alive_period.nanosec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``0`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-clean: client.clean_session ^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``false`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-unsub: client.unsubscribe_on_disconnect ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``true`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-maxreply-sec: client.max_reply_timeout.sec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``10`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-maxreply-nsec: client.max_reply_timeout.nanosec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``10`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-reconnect: client.reconnect ^^^^^^^^^^^^^^^^ :Required: No :Default: ``false`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-maxunack: client.max_unack_messages ^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``10`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-persistence: client.persistence ^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``none`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-persistencestorage: client.persistence_storage ^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-client-username: client.username ^^^^^^^^^^^^^^^ :Required: No :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-client-password: client.password ^^^^^^^^^^^^^^^ :Required: No :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-client-ssl-ca: client.ssl.ca ^^^^^^^^^^^^^ :Required: No :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-client-ssl-id: client.ssl.id ^^^^^^^^^^^^^ :Required: No :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-client-ssl-key: client.ssl.key ^^^^^^^^^^^^^^ :Required: No :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-client-ssl-key-passwd: client.ssl.key_password ^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-client-ssl-proto: client.ssl.protocol_version ^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``default`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-ssl-verifycert: client.ssl.verify_server_certificate ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``true`` :Description: :Accepted values: .. _section-adapter-xml-properties-client-ssl-cyphers: client.ssl.cypher_suites ^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``"ALL"`` :Description: :Accepted values: .. _section-adapter-xml-properties-sub: :litrep:`` Properties ---------------------------- .. list-table:: :litrep:`` Properties :widths: 90 10 :header-rows: 1 * - Property - Required * - :ref:`section-adapter-xml-properties-sub-topics` - Yes * - :ref:`section-adapter-xml-properties-sub-maxqos` - No * - :ref:`section-adapter-xml-properties-sub-queuesize` - No .. _section-adapter-xml-properties-sub-topics: subscription.topics ^^^^^^^^^^^^^^^^^^^ :Required: Yes :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-sub-maxqos: subscription.max_qos ^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``2`` :Description: :Accepted values: .. _section-adapter-xml-properties-sub-queuesize: subscription.queue_size ^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``0`` :Description: :Accepted values: .. _section-adapter-xml-properties-pub: :litrep:`` Properties ----------------------------- .. list-table:: :litrep:`` Properties :widths: 90 10 :header-rows: 1 * - Property - Required * - :ref:`section-adapter-xml-properties-pub-topic` - Yes* * - :ref:`section-adapter-xml-properties-pub-qos` - No * - :ref:`section-adapter-xml-properties-pub-retained` - No * - :ref:`section-adapter-xml-properties-pub-usemsginfo` - Yes* * - :ref:`section-adapter-xml-properties-pub-maxwait-sec` - No * - :ref:`section-adapter-xml-properties-pub-maxwait-nsec` - No .. _section-adapter-xml-properties-pub-topic: publication.topic ^^^^^^^^^^^^^^^^^ :Required: Yes (if :ref:`section-adapter-xml-properties-pub-usemsginfo` is not enabled). :Default: None :Description: :Accepted values: .. _section-adapter-xml-properties-pub-qos: publication.qos ^^^^^^^^^^^^^^^ :Required: No :Default: ``0`` :Description: :Accepted values: .. _section-adapter-xml-properties-pub-retained: publication.retained ^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``false`` :Description: :Accepted values: .. _section-adapter-xml-properties-pub-usemsginfo: publication.use_message_info ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: Yes (if :ref:`section-adapter-xml-properties-pub-topic` is empty). :Default: ``false`` :Description: :Accepted values: .. _section-adapter-xml-properties-pub-maxwait-sec: publication.max_wait_time.sec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``10`` :Description: :Accepted values: .. _section-adapter-xml-properties-pub-maxwait-nsec: publication.max_wait_time.nanosec ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Required: No :Default: ``0`` :Description: :Accepted values: