This is part 5 of my IoT series of blogs. So far we did look at the following topic
- Introduction into the planned scenario
- Building a Raspberry Pi based Smart Gateway
- ESP8266 and DHT22 based smart sensor
- Putting the Smart into the Smart IoT Device
In this blog we will create a first running version of the demo, with all elements simulated on one dockerhost.
Preparing the demo host
To be able to build and run the IoT demo, your system needs to have the following tools installed
- Ansible
- Docker
- Docker-Compose
- Maven
I am running the All-In-One-Demo via Docker-Machine on a Macbook.
Getting the code
I did create a single git repository for the ‘All in one Demo’. This repository has an Ansible-Playbook, which takes care of all the required steps needed to build and run the demo.
To retrieve the base code, clone the repository from github
==> git clone https://github.com/PatrickSteiner/IoT_Demo_AllInOne.git Cloning into 'IoT_Demo_AllInOne'... remote: Counting objects: 23, done. remote: Compressing objects: 100% (19/19), done. remote: Total 23 (delta 3), reused 18 (delta 1), pack-reused 0 Unpacking objects: 100% (23/23), done. Checking connectivity... done.
As with all my other demos, I heavily rely on Red Hat JBoss products instead of using pure Opensource community technologies. So please download the following products and place them into the ‘software’ subfolder of the newly cloned directory.
- JBoss EAP into directory `./software/`
- JBoss BPM Suite into directory `./software/`
- JBoss Fuse on Karaf into directory `./software/`
- JBoss DataGrid into directory `./software/`
- JBoss Data Grid 6.6.0 Library Module for JBoss EAP 6 into directory `./software/`
With all the files ready and in place, we can start the build procedure
==> ansible-playbook demo.yml < deleted lots of lines > TASK [Building the other images with docker-compose] ************************** changed: [localhost] PLAY RECAP ********************************************************************* localhost : ok=23 changed=16 unreachable=0 failed=0
Starting the Demo Environment
After a successful build of the demo environment, you can start it with
/Users/psteiner/Documents/RedHat/Demos/IoT_Demo_AllInOne ==> docker-compose up < deleted lots of lines > bpm_1 | 17:45:59,381 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://0.0.0.0:9990/management bpm_1 | 17:45:59,387 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://0.0.0.0:9990 bpm_1 | 17:45:59,387 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss EAP 6.4.0.GA (AS 7.5.0.Final-redhat-21) started in 183673ms - Started 1106 of 1143 services (82 services are lazy, passive or on-demand)
Note for Mac OS X user
If you, like myself, use an Apple as your dockerhost, then you will have to configure port-forwarding for some of the ports. This will make the handling of the demo much easier.
The following images shows which port-forwarding I configured.
Getting JBoss BPM Suite ready for the demo
Unfortunately JBoss BPM Suite requires two steps to be done manually – maybe because I do not now how it’s done otherwise …
You will have to logon to JBoss BPM Suite
You will have to build and deploy the process. To do so, please go to the “Project Authoring” page of JBoss BPM Suite
Make sure that you are in the right project, this should automatically be the case, if you followed the instructions so far. Build and deploy the project into the runtine of JBoss BPM Suite
Running the IoT Demo
Now that we have started the environment and deployed the process, we can start “playing” with it.
In “IoT_Demo_AllInOne/” you will find a simple script “run.sh” which starts a simulated sensor and sends one message with the following information:
Device-Type | temperature |
---|---|
Device-ID | 4711 |
Value | 20 |
Count | 50 |
/Users/psteiner/Documents/RedHat/Demos/IoT_Demo_AllInOne/IoT_Demo_Sensors ==> ./run.sh Starting the producer to send messages Connecting to tcp://localhost:1883 Publishing [B@6d311334
A quick way to verify, that the message has passed all steps of the demo, is to look at the output of the “docker-compose up” command, as this should still show the logs of all relevant elements of the demo.
These log entries tell us the following:
- line 1: Datacenter received a message of type ‘voltage’
- line 2: Message is stored in the Postgresql in the table ‘voltage’
- line 3: Message is processed by Rules system
Now let’s send a message, that will cause a rule to apply and trigger a process in JBoss BPM
/Users/psteiner/Documents/RedHat/Demos/IoT_Demo_AllInOne/ ==> ./runHigh.sh Starting the producer to send messages Connecting to tcp://localhost:1883 Publishing [B@6d311334
The log entries for this case are
- line 1: Datacenter received a message of type ‘voltage’
- line 2: Message is stored in the Postgresql in the table ‘voltage’
- line 3: Message is processed by Rules system
- line 4: Rules System identified this message require human interaction
- line 5: JBoss BPM Suite process initiated
- line 6: ignore … needs to be fixed 😉
- line 7 – 9: Rules System initiates the activitation of an alarm light ( not visible in this demo setup )
Now it’s time to go back to JBoss BPM Suite and work the initiated process by going to the “Task List”
The “Task List” shows one active, waiting human task. To get it’s details, click on the task on the list
To work the process, which in our context actually just is the acknowledgment of the received message, click the “Start” and then the “Complete” button.
This complete the introduction into the demo environment.
Please follow this blog for more detailed articles on
- what’s happening behind the scenes of the IoT Demo
- how to run it with real physical Sensors and a Smart Gateway