Skip to content

ishuverma/Virtual_IoT_Gateway

 
 

Repository files navigation

Build Intelligent IoT Gateway for Arm 64 based Platforms

toc::[]114

Overview

Intelligent IoT Gateway is a key component of enterprise Internet of Things (IoT) as it enables real time decision-making at the edge, secures downstream devices and optimizes network utilization. In this lab, you’ll learn how to build the Intelligent IoT Gateway with an Arm 64 platform - for this lab we used APM’s Mustang platform but any other Arm 64 platform with RHEL should work as well. Key components of the Gateway are:

  • Red Hat Enterprise Linux Developer Preview for Arm to provide Enterprise class foundation

  • JBOSS Fuse to transform sensor data and route it to end points

  • JBOSS BRMS to enable real-time decision making at the edge

  • JBOSS A-MQ to arbitrate sensor data

The first part of this lab is to install required software (Maven, JDK). Once the Gateway is provisioned, we’ll put it into action by starting JBOSS Fuse, building & deploying the pre-built routing and business rules services. We’ll then start sensor app that sends temperature data using MQTT to the JBOSS A-MQ broker. These messages will be forwarded to the services that we started earlier. Finally, we’ll be creating the business rules to trigger desired action when the sensor value reaches a threshold.

Requirements

  • Install Red Hat Enterprise Linux 7.3 Developer Preview for Arm

  • Download JBOSS Fuse 6.2.1 from the Red Hat Customer Portal and save it in the Downloads folder

download fuse

Step 1 - Prepare the system

Enable the required repos, install maven, install fuse and clone the project:

  • Open a terminal and enter the following commands:

    [demo-user@localhost ~]$ subscription-manager repos --enable=rhel-7-for-arm-optional-rpms
    [demo-user@localhost ~]$ sudo yum install maven
    [demo-user@localhost ~]$ unzip Downloads/jboss-fuse-full-6.2.1.redhat-084.zip
    [demo-user@localhost ~]$ ln -s jboss-fuse-6.2.1.redhat-084 fuse
    [demo-user@localhost ~]$ git clone -b Arm-64-Platform https://github.com/ishuverma/Virtual_IoT_Gateway

Step 2 - Start JBoss Fuse Server

  • Open a new shell and enter the following commands:

    [demo-user@localhost ~]$ cd
    [demo-user@localhost ~]$ cd Virtual_IoT_Gateway
    [demo-user@iotlab Virtual_IoT_Gateway]$ ./runJBossFuse.sh
  • Wait for the Red Hat JBoss Fuse to complete the start procedure

fuse started

Red Hat JBoss Fuse needs to install the 'camel-mqtt' OSGi features to process MQTT messages.

  • Enter the following simple command on the 'JBossFuse' command prompt

    JBossFuse:karaf@root> features:install camel-mqtt

Step 3 - Build Software Sensor

For this lab, we’ll be using a software sensor that simulates a physical sensor. Defined by a few environment variables, software sensor creates random values and sends these to a MQTT Broker for further processing.

To be able to run the Software Sensor, it has to be built from the source files.

  • Open a new terminal and enter the following commands:

    [demo-user@iotlab Virtual_IoT_Gateway]$ cd Software_Sensor/
    [demo-user@iotlab Software_Sensor]$ mvn clean install

Step 4 - Build and Deploy Camel Route

The sensor data will be transformed and routed by a camel route provided in this project. Now we need to build the Red Hat JBoss Fuse project and deploy it to our running JBoss Fuse server. We’ll use the provided script to build and deploy the project.

  • In a new terminal, perform the following commands

    [demo-user@iotlab Software_Sensor]$ cd
    [demo-user@iotlab ~]$ cd Virtual_IoT_Gateway/
    [demo-user@iotlab Virtual_IoT_Gateway]$ ./runRoutingService.sh

We can verify that the Camel route has been deployed by logging into JBOSS Fuse admin cosole see details

Step 5: Build and Run the Business Rules Service

One of the important functions of Intelligent IoT Gateway is trigger action if the sensor data meets certain condition defined by business rules. We’ve a business rules service that ensures:

  1. Sensor data is read from a Message queue

  2. Sensor data is handed over to the rules execution engine that triggers action per defined rules

  3. Altered data is placed into another defined Message queue

Lets build a new version of the service and start it.

  • Enter the following commands in a terminal

    [demo-user@localhost Virtual_IoT_Gateway]$ cd
    [demo-user@localhost ~]$ cd Virtual_IoT_Gateway/
    [demo-user@localhost Virtual_IoT_Gateway]$ ./runRulesService.sh

It should display following output < output truncated > AMQ-Broker tcp://localhost:61616 ready to work!

Device-Type = temperature
Device-ID   = 4711
Payload     = 70
Result      = 1
----------------------
Sending <?xml version="1.0" encoding="UTF-8" standalone="yes"?><dataSet><timestamp>18.05.2016 10:46:22 766</timestamp><deviceType>temperature</deviceType><deviceID>4711</deviceID><payload>70</payload><required>0</required><average>0.0</average><errorCode>1</errorCode></dataSet>

Step 6: Test Rule Service

We will try this service by sending a test message via the Software Sensor to our setup. The following should happen:

Software Sensor sends a message with a high value via MQTT

Routing Service will pick it up, transform the message and send it to an AMQP message queue

Business Rules Service will take the transformed message from the queue and will put it in another AMQP message queue, but only if it meets the business rule condition

  • Enter the following commands in a new terminal

    [demo-user@localhost Desktop]$ cd
    [demo-user@localhost ~]$ cd √/
    [demo-user@localhost Virtual_IoT_Gateway]$ ./runHighSensor.sh

It should display following output

Starting the producer to send messages
Sending '70,0'
AMQ-Broker tcp://localhost:61616 ready to work!
Device-Type = temperature
Device-ID   = 4711
Payload     = 70
Result      = 1
----------------------
Sending <?xml version="1.0" encoding="UTF-8" standalone="yes"?><dataSet><timestamp>17.05.2016 15:08:59 265</timestamp><deviceType>temperature</deviceType><deviceID>4711</deviceID><payload>70</payload><required>0</required><average>0.0</average><errorCode>1</errorCode></dataSet>
----------------------

Another way to verify that the message was properly processed is to take a look at Red Hat JBoss Fuse console via 'http://<ip address of Arm system>:8181', The count of messages enqueued and dequeued should now show that one message has been taken from 'message.to.rules' and placed into 'message.to.datacenter'. This was per the business rules defined by the decision table i.e. if the temperature exceeds a threshold then the message should be sent to datacenter.

Note: Fuse console login/password is admin/change12_me

testResult

--------------------- End of Lab ---------------------

About

IoT Lab Series: Building Intelligent IoT Gateway

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 88.0%
  • Shell 12.0%