1.4. Connecting an ApplicationEdgeX provides exporters for a variety of cloud services and application. To keep this guide simple, we’re going to use a public MQTT broker hosted by HiveMQ, then watch for our EdgeX readings to be pushed to it automatically.
To register the application as an export client, run:
<span class="n">curl</span> <span class="o">-</span><span class="n">X</span> <span class="n">POST</span> <span class="o">-</span><span class="n">d</span> <span class="s1">'{</span>
<span class="s2">"name"</span><span class="p">:</span><span class="s2">"QuickStartExport"</span><span class="p">,</span>
<span class="s2">"addressable"</span><span class="p">:{</span>
<span class="s2">"name"</span><span class="p">:</span><span class="s2">"HiveMQBroker"</span><span class="p">,</span>
<span class="s2">"protocol"</span><span class="p">:</span><span class="s2">"tcp"</span><span class="p">,</span>
<span class="s2">"address"</span><span class="p">:</span><span class="s2">"broker.hivemq.com"</span><span class="p">,</span>
<span class="s2">"port"</span><span class="p">:</span><span class="mi">1883</span><span class="p">,</span>
<span class="s2">"publisher"</span><span class="p">:</span><span class="s2">"EdgeXExportPublisher"</span><span class="p">,</span>
<span class="s2">"topic"</span><span class="p">:</span><span class="s2">"EdgeXQuickStartGuide"</span>
<span class="p">},</span>
<span class="s2">"format"</span><span class="p">:</span><span class="s2">"JSON"</span><span class="p">,</span>
<span class="s2">"filter"</span><span class="p">:{</span>
<span class="s2">"deviceIdentifiers"</span><span class="p">:[</span><span class="s2">"Random-Integer-Generator01"</span><span class="p">]</span>
<span class="p">},</span>
<span class="s2">"enable"</span><span class="p">:</span><span class="n">true</span><span class="p">,</span>
<span class="s2">"destination"</span><span class="p">:</span><span class="s2">"MQTT_TOPIC"</span>
<span class="p">}</span><span class="s1">' http://localhost:48071/api/v1/registration</span>
You can connect to this broker with any MQTT client to watch the data being sent. HiveMQ provides a web-based client that you can use, simply subscribe to the “EdgeXQuickStartGuide” topic and you will begin seeing your random number readings.
You can also use the Mosquitto CLI tool to verify that readings are being sent by running:
<span class="n">mosquitto_sub</span> <span class="o">-</span><span class="n">h</span> <span class="n">broker</span><span class="o">.</span><span class="n">hivemq</span><span class="o">.</span><span class="n">com</span> <span class="o">-</span><span class="n">p</span> <span class="mi">1883</span> <span class="o">-</span><span class="n">t</span> <span class="n">EdgeXQuickStartGuide</span>
|