<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.commander4j.com/index.php?action=history&amp;feed=atom&amp;title=MQTT</id>
	<title>MQTT - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.commander4j.com/index.php?action=history&amp;feed=atom&amp;title=MQTT"/>
	<link rel="alternate" type="text/html" href="https://wiki.commander4j.com/index.php?title=MQTT&amp;action=history"/>
	<updated>2026-11-23T12:43:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.commander4j.com/index.php?title=MQTT&amp;diff=2016&amp;oldid=prev</id>
		<title>Dgarratt: Updated by push_wiki.py</title>
		<link rel="alternate" type="text/html" href="https://wiki.commander4j.com/index.php?title=MQTT&amp;diff=2016&amp;oldid=prev"/>
		<updated>2026-11-09T20:47:23Z</updated>

		<summary type="html">&lt;p&gt;Updated by push_wiki.py&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;The MQTT [[Connectors|connector]] publishes a message to an MQTT broker. It is an &amp;#039;&amp;#039;&amp;#039;output&amp;#039;&amp;#039;&amp;#039; connector only. A typical use is passing a value from a file, such as a production count, to a dashboard or another system that subscribes to the topic.&lt;br /&gt;
&lt;br /&gt;
== Map configuration ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;config.xml&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;output&amp;gt;&lt;br /&gt;
   &amp;lt;id&amp;gt;out1&amp;lt;/id&amp;gt;&lt;br /&gt;
   &amp;lt;enabled&amp;gt;true&amp;lt;/enabled&amp;gt;&lt;br /&gt;
   &amp;lt;description&amp;gt;Send to MQTT Broker&amp;lt;/description&amp;gt;&lt;br /&gt;
   &amp;lt;type&amp;gt;MQTT&amp;lt;/type&amp;gt;&lt;br /&gt;
   &amp;lt;url&amp;gt;&lt;br /&gt;
      &amp;lt;path&amp;gt;./interface/output/XML MQTT&amp;lt;/path&amp;gt;&lt;br /&gt;
      &amp;lt;prefix/&amp;gt;&lt;br /&gt;
      &amp;lt;fileExtension/&amp;gt;&lt;br /&gt;
      &amp;lt;use83GUID&amp;gt;false&amp;lt;/use83GUID&amp;gt;&lt;br /&gt;
      &amp;lt;retainOriginalFilename&amp;gt;false&amp;lt;/retainOriginalFilename&amp;gt;&lt;br /&gt;
   &amp;lt;/url&amp;gt;&lt;br /&gt;
   &amp;lt;mqtt&amp;gt;&lt;br /&gt;
      &amp;lt;mqttBroker&amp;gt;tcp://broker.example.com:1883&amp;lt;/mqttBroker&amp;gt;&lt;br /&gt;
      &amp;lt;mqttTopic&amp;gt;factory/line1/production&amp;lt;/mqttTopic&amp;gt;&lt;br /&gt;
      &amp;lt;mqttClient&amp;gt;middleware4j-line1&amp;lt;/mqttClient&amp;gt;&lt;br /&gt;
      &amp;lt;mqttContentXPath&amp;gt;/message/messageData/productionDeclaration/productionQuantity&amp;lt;/mqttContentXPath&amp;gt;&lt;br /&gt;
      &amp;lt;mqttQos&amp;gt;2&amp;lt;/mqttQos&amp;gt;&lt;br /&gt;
   &amp;lt;/mqtt&amp;gt;&lt;br /&gt;
&amp;lt;/output&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Setting !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;type&amp;#039;&amp;#039;&amp;#039; || &amp;lt;code&amp;gt;MQTT&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;url / path&amp;#039;&amp;#039;&amp;#039; || A folder. A small report of each publish is written here. See below.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;mqtt / mqttBroker&amp;#039;&amp;#039;&amp;#039; || Address of the broker, for example &amp;lt;code&amp;gt;tcp://broker.example.com:1883&amp;lt;/code&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;mqtt / mqttTopic&amp;#039;&amp;#039;&amp;#039; || The topic to publish to.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;mqtt / mqttClient&amp;#039;&amp;#039;&amp;#039; || The client identifier this connection presents to the broker. Each client connected to a broker needs a different identifier.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;mqtt / mqttContentXPath&amp;#039;&amp;#039;&amp;#039; || An XPath expression selecting the element whose text is published as the message. Required.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;#039;&amp;#039;&amp;#039;mqtt / mqttQos&amp;#039;&amp;#039;&amp;#039; || Quality of service: 0, 1 or 2.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The settings shared by all connectors are described on the [[Maps]] page.&lt;br /&gt;
&lt;br /&gt;
== What is published ==&lt;br /&gt;
&lt;br /&gt;
The message is the text of the one element selected by &amp;lt;code&amp;gt;mqttContentXPath&amp;lt;/code&amp;gt;. With the settings above and a Commander4j production declaration as input, the message published would be the production quantity, for example &amp;lt;code&amp;gt;5616.000&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To publish something built from several values, add a stylesheet to the map that assembles the text into one element and point &amp;lt;code&amp;gt;mqttContentXPath&amp;lt;/code&amp;gt; at that element.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;xsl:template match=&amp;quot;/message/messageData/productionDeclaration&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;mqtt&amp;gt;&lt;br /&gt;
      &amp;lt;payload&amp;gt;&amp;lt;xsl:value-of select=&amp;quot;SSCC&amp;quot;/&amp;gt;;&amp;lt;xsl:value-of select=&amp;quot;material&amp;quot;/&amp;gt;;&amp;lt;xsl:value-of select=&amp;quot;productionQuantity&amp;quot;/&amp;gt;&amp;lt;/payload&amp;gt;&lt;br /&gt;
   &amp;lt;/mqtt&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;&amp;amp;lt;mqttContentXPath&amp;amp;gt;/mqtt/payload&amp;amp;lt;/mqttContentXPath&amp;amp;gt;&amp;lt;/code&amp;gt; this publishes &amp;lt;code&amp;gt;000000000000000123;43170672;5616.000&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== The report file ==&lt;br /&gt;
&lt;br /&gt;
For each message a text file ending in &amp;lt;code&amp;gt;.mqtt&amp;lt;/code&amp;gt; is written to the output folder. It lists the broker, client, topic and quality of service, the message that was published, and each step of the connection, ending with the word SUCCESS. It is a simple record that the message was sent.&lt;br /&gt;
&lt;br /&gt;
The sample map &amp;#039;&amp;#039;&amp;#039;map429&amp;#039;&amp;#039;&amp;#039; in &amp;lt;code&amp;gt;samples/advanced/config/config.xml&amp;lt;/code&amp;gt; shows an MQTT output.&lt;br /&gt;
&lt;br /&gt;
See also: [[Connectors]], [[Maps]], [[SOCKET]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Middleware4j]]&lt;/div&gt;</summary>
		<author><name>Dgarratt</name></author>
	</entry>
</feed>