toc::[]114
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.
-
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
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
-
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
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
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
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
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:
-
Sensor data is read from a Message queue
-
Sensor data is handed over to the rules execution engine that triggers action per defined rules
-
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>
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
--------------------- End of Lab ---------------------