Skip to main content
AI
  • Get started with AI

    • Red Hat AI

      Accelerate the development and deployment of enterprise AI solutions.

    • AI learning hub

      Explore learning materials and tools, organized by task.

    • AI interactive demos

      Click through scenarios with Red Hat AI, including training LLMs and more.

    • AI/ML learning paths

      Expand your Red Hat OpenShift AI knowledge using these learning resources.

    • AI quickstarts

      Focused AI use cases designed for fast deployment on Red Hat AI platforms.

    • No-cost AI training

      Foundational Red Hat AI training.

  • Featured resources

    • Red Hat OpenShift AI
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

Red Hat AI Factory with NVIDIA

Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.

Learn
  • Self-guided

    • Documentation

      Find answers, get step-by-step guidance, and learn how to use Red Hat products.

    • Learning paths

      Explore curated walkthroughs for common development tasks.

    • Guided learning

      Receive custom learning paths powered by our AI assistant.

    • See all learning
  • Hands-on

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

    • Interactive labs

      Learn by doing in these hands-on, browser-based experiences.

    • Interactive demos

      Click through product features in these guided tours.

  • Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics
  • Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
Build
  • Get started

    • Red Hat build of Podman Desktop

      A downloadable, local development hub to experiment with our products and builds.

    • Developer Sandbox

      Spin up Red Hat's products and technologies without setup or configuration.

  • Download products

    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products
  • Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset
  • References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
Community
  • Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions
  • Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github
  • Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

Join the Red Hat Developer program

Download Red Hat products and project builds, access support documentation, learning content, and more.

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

How to Build an Intelligent IoT Gateway in 7 Easy Steps

November 2, 2016
Ishu Verma
Related topics:
Linux
Related products:
Streams for Apache KafkaRed Hat Fuse

    In previous blogs, I talked about the the critical role of the IoT gateway in the enterprise Internet of Things (IoT) as it enables real time decision-making at the edge, secures downstream devices and optimizes network utilization. So how does one go about building this gateway? In this blog, you’ll learn how to build an intelligent IoT gateway in a few simple steps - you can find the code at  GitHub.

    To automate the gateway provisioning, we’ll using Ansible by Red Hat. Why? Because it is the simplest and best tool out there for this job. Besides, it can also be used for configuration management and application deployment. Once you’re ready to provision and deploy thousands of gateways in a production environment, you can use this same Ansible tool. This is how IT departments provision the systems securely across the network.

    The gateway we are building here can run on physical hardware or in a virtual machine as long as they’re running Red Hat Enterprise Linux 7.2.

    The main components of the gateway are:

    • Red Hat Enterprise Linux: Provides enterprise-class foundation
    • Red Hat JBoss A-MQ: Arbitrates sensor data
    • Red Hat JBoss Fuse: Transforms sensor data and routes it to end points
    • Red Hat JBoss BRMS: Enables real-time decision making at the edge

    Once the gateway is provisioned, we’ll put it into action by starting Red Hat JBoss Fuse and building and deploying the routing and business rules services. We’ll then start a sensor application that sends temperature data using MQTT to the Red Hat 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 the desired action when the sensor value reaches a threshold.

    Note: Before you get started, you need to have Red Hat JBoss Fuse 6.2.1 in the Downloads folder of the gateway. You can download it from the Red Hat Customer Portal.

    Step 1 - Prepare the Host system with Ansible

    Clone the project repo on the host machine.

    • Open a terminal and enter the following commands:
    [user@localhost ~]$ git clone -b Virtual-Lab-1-Host https://github.com/RedHat-IoT/Virtual_IoT_Gateway.git
    • Update the host file [Virtual-IoT-Gateway/Ansible/host] with he tIP address of the gateway and place the public key of the host on the remote gateway (Ansible uses ssh to communicate with the remote system). You can learn how to set up Ansible here.
    • Update the Ansible playbook BuildGW file [Virtual-IoT-Gateway/Ansible/BuildGW] for the username for your gateway: set_fact: user='user name'
    • Launch the Ansible playbook by entering the following commands:
    [user@localhost ~]$ cd Virtual_IoT_Gateway/Ansible
    [user@localhost ~]$ ansible-playbook BuildGW

    Let Ansible run through the tasks in the playbook. Once Ansible is finished, we’re ready to start work directly on the gateway.

    Step 2 - Login to the Gateway

    Note: For my gateway, I’m using username = 'demo-user' and password = 'change12_me'.

    Step 3 - Start the Red Hat JBoss Fuse Server

    • Open a new shell and enter the following commands:
    [demo-user@localhost ~]$ cd
    [demo-user@localhost ~]$ cd IoT_Summit_Lab
    [demo-user@iotlab IoT_Summit_Lab]$ ./runJBossFuse.sh
    
    • Wait for the Red Hat JBoss Fuse server 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
    • Minimize this shell to keep the Fuse server running in the background:

    Step 4 - Build and Deploy the 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 Fuse server. We’ll use the provided script to build and deploy the project.

    • In a terminal, perform the following commands:
    [demo-user@iotlab Software_Sensor]$ cd
    [demo-user@iotlab ~]$ cd IoT_Summit_Lab/
    [demo-user@iotlab IoT_Summit_Lab]$ ./runRoutingService.sh
    

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

    Step 5 - Create Business Rules

    One of the important functions of an intelligent IoT gateway is to trigger action if the sensor data meets certain conditions defined by business rules. In this section we’ll learn how to create a business rules service. This service will work the following way:

    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.

    We’ll use an MS Excel decision table to define the business rules. The following image shows an example of a decision table where each row represents a rule. The blue columns are 'conditions' and the yellow column defines an 'action'.

    Rules syntax is pretty simple: If some condition, then some action

    The rules system is capable of reading the rules from a spreadsheet and compile them into rules in the above syntax. For this lab, a sample business rule spreadsheet is provided that can be used to create new rules.

    The columns in this table represent the following:

    Alerting Rule: Name of the rule. It is an optional field but very useful for debugging

    Device Type: Type of device reported by the sensor

    Payload: Number-range this rule will need to match with

    Result: Action triggered by the rule i.e. changing value to 0 or 1

    • Open the sample rules spreadsheet: 'DecisionTable.xls'
    • Create two rules by filling in the following information:
      • Rule 1: If we get a temperature reading between 0 and 60, change the result field to 0
      • Rule 2: If we get a temperature reading between 61 and 100, change the result field to 1

    Note: In the 2nd rule Payload column, add a space between “61,” and “100”

    Note: Save the spreadsheet in MS Excel format.

    The details on the Business Rules Service are here.

    Step 6: Build and Run the Business Rules Service

    Now that we have added a few rules to our decision table, we need to build a new version of the service and start it.

    • Enter the following commands in a terminal:
    [demo-user@localhost IoT_Summit_Lab]$ cd
    [demo-user@localhost ~]$ cd IoT_Summit_Lab/
    [demo-user@localhost IoT_Summit_Lab]$ ./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 18.05.2016 10:46:22 766temperature47117000.01
    

    Step 7: Test the Rules 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 IoT_Summit_Lab/
    [demo-user@localhost IoT_Summit_Lab]$ ./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 17.05.2016 15:08:59 265temperature47117000.01
    ----------------------

    Another way to verify that the message was properly processed is to take a look at Red Hat JBoss Fuse console via 'http://localhost: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'.

    Note: The Fuse console login/password is admin/change12_me

    Conclusion

    Building an intelligent IoT gateway is a very simple process with the Ansible by Red Hat automation tool. The enterprise-grade intelligent IoT gateway based on open source technologies is built with Red Hat Enterprise Linux, Red Hat JBoss Fuse, Red Hat JBoss BRMS and Red Hat JBoss A-MQ.

    We have provided the example code to put the intelligent IoT gateway to use by deploying the routing and business rules services. The sensor application is used to send temperature data to the A-MQ broker. These MQTT messages were processed by the services that we started earlier. Finally, we created the business rules to trigger desired action when the sensor value reaches a threshold.

    The source code for for building the Intelligent IoT Gateway including the video walkthrough is available at  GitHub.

     

    Last updated: September 3, 2019

    Recent Posts

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    • Control multicluster costs with right-sizing in Red Hat Advanced Cluster Management 5

    • Lightbits is now certified for Red Hat OpenStack Services on OpenShift

    Red Hat Developers logo

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    Red Hat Developer

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility
    Ask AI