4. Integrate FogFlow with FIWARE

As an official Generic Enabler (GE) in the FIWARE ecosystem, FogFlow holds a unique position as Cloud-Edge Orchestrator to launch and manage dynamic data processing flows seamlessly over cloud and edges for data ingestion, transformation, and also advanced analytics.

As illustrated by the following picture, FogFlow can interwork with other FIWARE GEs to power FIWARE-based IoT Platforms at the following two layers. At the upper layer, FogFlow can interwork with Orion Broker via the standardized NGSI interface in the following two ways.

4.1. Orion Broker as the Destination

4.1.1. Integrate FogFlow with Orion Broker

4.2. Start Up Orion

You may follow the orion docs to set up a Orion Context Broker instance from here: Installing Orion.

You may also setup Orion on docker using below commands.(docker is required this method) Note: Orion container has a dependency on MongoDB database.

Prerequisite: Docker should be installed.

First launch MongoDB container using below command:

sudo docker run --name mongodb -d mongo:3.4

And then run Orion with this command

sudo docker run -d --name orion1 --link mongodb:mongodb -p 1026:1026 fiware/orion -dbhost mongodb

Check that everything works with

curl http://<Orion IP>:1026/version

Note: Allow port 1026 in firewall for public access.

4.3. Issue a subscription to forward the generated result to Orion Context Broker

Use the following curl request to subscribe Fogflow Broker to FIWARE Orion:

curl -iX POST \
  'http://coreservice_ip/ngsi10/subscribeContext' \
  -H 'Content-Type: application/json'  \
  -H 'Destination: orion-broker'  \
  -d '
  "entities": [
      "id": ".*",
      "type": "Result",
      "isPattern": true
  "reference": "http://<Orion IP>:1026/v2/op/notify"

Please note that this subscription request does not use any restrictions and attributes, it is a general subscription request based of entity type.

4.4. Query the result from Orion Context Broker

Visit the following URL in your browser and search for the desired context entities:

curl http://<Orion IP>:1026/v2/entities/

The first way is to consider Orion Broker as the destination of any context information generated by a FogFlow IoT service. In this case a NGSI subscription must be issued by an external application or FogFlow Dashboard to ask FogFlow to forward the requested context updates to a specified Orion Broker.


Two ways are provided to tell FogFlow which entitie should be forwarded to the Orion Broker. The first way is to issue a raw subscription to FogFlow Broker. The second way is to write a small JavaScript program to do this. Examples are provided below. Notice that the integration is using the NGSI V2 interface of Orion Broker.


  • fogflowBroker: IP address of the FogFlow Broker, it could be “webportal_ip” or “coreservice_ip” in the configuration file. This is up to where you access the FogFlow system.
  • orionBroker: the accessible IP address of your Orion Running Instance.
curl -iX POST \
  'http://fogflowBroker:8080/ngsi10/subscribeContext' \
  -H 'Content-Type: application/json' \
  -H 'Destination: orion-broker' \
  -d '{"entities": [{"type": "PowerPanel", "isPattern": true}],
                            "reference": "http://orionBroker:1026/v2/op/notify"} '
// please refer to the JavaScript library, located at  https://github.com/smartfog/fogflow/tree/master/designer/public/lib/ngsi

//  entityType: the type of context entities to be pushed to Orion Broker
//  orionBroker: the URL of your running Orion Broker
function subscribeFogFlow(entityType, orionBroker)
    var subscribeCtxReq = {};
    subscribeCtxReq.entities = [{type: entityType, isPattern: true}];
    subscribeCtxReq.reference =  'http://' + orionBroker + '/v2/op/notify';

    client.subscribeContext4Orion(subscribeCtxReq).then( function(subscriptionId) {
    }).catch(function(error) {
        console.log('failed to subscribe context');

// client to interact with IoT Broker
var client = new NGSI10Client(config.brokerURL);

subscribeFogFlow('PowerPanel', 'cpaasio-fogflow.inf.um.es:1026');

To verify if the requested data has been pushed to your Orion Broker, you can send the following NGSI v2 query to check it.

curl http://orionBroker:1026/v2/entities?type=PowerPanel -s -S -H 'Accept: application/json'

4.5. Orion Broker as a Data Source

The second way is to consider Orion Broker as a data source to provide additional information. In this case we can implement a simple fog function to fetch any necessary information into the FogFlow system. In either way there is no need to make any change to the existing Orion-based FIWARE system. Therefore, this type of integration can be done fast with nearly zero effort.

At the low layer, for the integration with any Non-NGSI supported devices like MQTT, COAP, OneM2M, OPC-UA, LoRaWAN, FogFlow can reuse the modules of existing IoT agents and transform them into FogFlow adapters based on the fog function programming model. With these adapters FogFlow can dynamically launch necessary adapters for device integration directly at edges. This way FogFlow is able to talk with a wide range of IoT devices.