EdgeX in Action, Part 4: Exporting Messages to Cloud

This is the forth article in series “EdgeX in Action”, and in this article we will see how to export messages from IoT edge gateway to the remote server in the cloud.

Drasko DRASKOVIC
Mainflux IoT Platform
3 min readSep 8, 2018

--

We at Mainflux are building one of the world’s first EdgeX-compliant IoT gateways called MFX-1. Our vision is producing end-to-end open-source IoT system — from the edge to the cloud — where fleets of MFX-1 EdgeX gateways are connected to Mainflux IoT cloud and managed via web applications.

In the previous article, “EdgeX in Action, Part 3: Sending Commands and Events”, we have took a examined how gateway talks to devices (south interface). In this article we’ll see how it talks to the cloud (north interface).

In order to send messages to the cloud, EdgeX Foundry system uses Export Services — a set of services living on the top of the EdgeX stack that is used to send data to remote servers via HTTP or MQTT protocol. You can learn more about Export services from project’s official documentation.

Main actors in Export Services layer are Export Registration and Export Distribution microservices.

Export Registration is simple — it provides an API for the user to input the data that are needed for sending messages to the cloud — like to which MQTT topic to shoot the data or which credentials to use for access. Export Distribution service will later use this data.

Export Distribution has another role: to push the data to the cloud, either by issuing HTTP POST or MQTT PUB. It gets the necessary metadata (which topic/URL, which API key, TLS or not, etc.) from Export Registration. In order to to increase performance, Export Data keeps it’s own cache of this information which is updated by events coming from Export Registration.

Registering Export Client

In order to configure (provision) the system for exporting messages, we must talk to Export Registration via API it exposes and register an export client:

As you can see, in this example we are telling Export Services to publish messages using MQTT protocol, to MQTT test server on the standard 1883 port and on the topic edgex/data.

Let’s see if this went well by querying Export Registration service:

Now we are ready to test the set-up.

Testing Message Publishing

As we saw in the previous post, Events are sent by issuing POST on http://loclahost:48080/api/v1/event. But before issuing these events let’s subscribe to test.mosquitto.org on the topic export/data:

Now, let’s try shooting some events from EdgeX running on local PC:

You should see messages coming to your subscribed MQTT client, something like this:

That’s it. Easy, isn’t it?

Now that we saw how to send messages from devices, though the EdgeX IoT gateway all the way to the remote MQTT server in the cloud and then to our application on the top of this cloud (mosquitto_sub in this case), we are ready for creating ultimate end-to-end open-source IoT solution: EdgeX and Mainflux combo — an IoT match made in heaven! And this is what we will cover in the next article, “EdgeX in Action, part 5: Connecting to Mainflux”.

To learn more about Mainflux and how we’re building the world’s most sophisticated open-source Industrial IoT cloud, visit our website and follow us on Twitter!

--

--