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

4 steps to set up the MQTT secure client for Red Hat AMQ 7.4 on OpenShift

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

September 25, 2019
Chandra Shekhar Pandey
Related topics:
JavaKubernetes
Related products:
AMQ ClientsStreams for Apache KafkaRed Hat OpenShift

    In this article, we show how to set up Red Hat AMQ 7.4 on Red Hat OpenShift. Also, we show how to connect the external Message Queuing Telemetry Transport (MQTT) secure client to the AMQ 7.4 platform. MQTT is a Java-based client that uses the Eclipse Paho library and can publish and consume messages from Red Hat AMQ 7.4 Broker on OpenShift using secure transport. These commands and code have been verified with OpenShift 3.11.

     

    Follow the steps below to perform this activity.

    Step 1: Create a secret and a service account

    In a new OpenShift project, create a secret and a service account with the view role:

    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc new-project amq-demo
    [cpandey@cpandey AMQ74_CERTIFICATE]$ echo '{"kind": "ServiceAccount", "apiVersion": "v1", "metadata": {"name": "amq-service-account"}}' | oc create -f -
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc policy add-role-to-user view system:serviceaccount:amq-demo:amq-service-account
    [cpandey@cpandey AMQ74_CERTIFICATE]$ keytool -genkey -alias broker -keyalg RSA -keystore broker.ks
    [cpandey@cpandey AMQ74_CERTIFICATE]$ keytool -export -alias broker -keystore broker.ks -file broker_cert
    [cpandey@cpandey AMQ74_CERTIFICATE]$ keytool -genkey -alias client -keyalg RSA -keystore client.ks
    [cpandey@cpandey AMQ74_CERTIFICATE]$ keytool -import -alias broker -keystore client.ts -file broker_cert
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc create secret generic amq-app-secret --from-file=broker.ks
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc secrets add sa/amq-service-account secret/amq-app-secret
    

    Note: All of these steps are mentioned in the official Red Hat Documentation, with details.

    Step 2: Deploy Red Hat AMQ 7.4 Broker

    Deploy Red Hat AMQ 7.4 broker using the OpenShift web console:

    1. Broker setup is easy with the OpenShift GUI. In the amq-demo project, browse the catalog and search for the template Red Hat A-MQ 7.4 (Ephemeral with SSL). The following six figures describe the information that you need to fill in for Broker setup. Once the configuration is complete, click the Create button:
    Browse Catalog
    1. Browse Catalog
    Select Template
    2. Select Template
    Configuration-1
    3. Configuration-1
    Configuration-2
    4. Configuration-2
    Configuration-3
    5. Configuration-3
    Final Step
    6. Final Step
    1. Run the following commands to check for services and pods. After a successful setup, you should have these available:
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc get service|grep ssl
    brokertest-amq-amqp-ssl ClusterIP 172.30.4.207 5671/TCP 2m
    brokertest-amq-mqtt-ssl ClusterIP 172.30.145.232 8883/TCP 2m
    brokertest-amq-stomp-ssl ClusterIP 172.30.20.224 61612/TCP 2m
    brokertest-amq-tcp-ssl ClusterIP 172.30.160.172 61617/TCP 2m
    [cpandey@cpandey AMQ74_CERTIFICATE]$
    
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc get pod
    NAME READY STATUS RESTARTS AGE
    brokertest-amq-1-z2xjq 1/1 Running 0 3m
    [cpandey@cpandey AMQ74_CERTIFICATE]$
    1. Now, create a route in the current project (amq-demo) for the MQTT service brokertest-amq-mqtt-ssl so that external clients can access Red Hat AMQ 7.4 in OpenShift. Set this route's termination type to passthrough so that the encrypted traffic goes to Red Hat AMQ 7.4 broker and TLS termination is not done at the route, specifically:
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc create route passthrough --service brokertest-amq-mqtt-ssl route.route.openshift.io/brokertest-amq-mqtt-ssl created
    1. Now, if we check routes available in the current project (amq-demo):
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc get route
    NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
    brokertest-amq-mqtt-ssl brokertest-amq-mqtt-ssl-amq-demo.192.168.42.111.nip.io brokertest-amq-mqtt-ssl passthrough None
    console console-amq-demo.192.168.42.111.nip.io brokertest-amq-jolokia passthrough None
    [cpandey@cpandey AMQ74_CERTIFICATE]$
    

    Step 3: Set up the Java MQTT client

    Now, set up the Java MQTT client external to your OpenShift environment. Once the route is configured, we just have to provide that URL in our client. Check out my personal GitHub code for examples:

    • For the MQTT publisher client, check out MqttPublishSample.java.
    • For the MQTT subscriber client, check out MqttSubscribeSample.java .
    • To execute these clients, use ThreadFactory.java.

    Note that we are using the client truststore client.ts, which we generated in Step 1.

    Step 4: Monitor topic statistics

    Now that you're set up, you can monitor your topic statistics:

    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc get pods
    NAME READY STATUS RESTARTS AGE
    brokertest-amq-1-z2xjq 1/1 Running 0 14m
    [cpandey@cpandey AMQ74_CERTIFICATE]$ oc rsh brokertest-amq-1-z2xjq
    sh-4.2$ cd /opt/amq/bin
    sh-4.2$ ./artemis queue stat
    OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
    |NAME |ADDRESS |CONSUMER_COUNT |MESSAGE_COUNT |MESSAGES_ADDED |DELIVERING_COUNT |MESSAGES_ACKED |
    |DLQ |DLQ |0 |0 |0 |0 |0 |
    |ExpiryQueue |ExpiryQueue |0 |0 |0 |0 |0 |
    |activemq.management.b75e216e-902d-4393-8961-4a45dc54e4b6|activemq.management.b75e216e-902d-4393-8961-4a45dc54e4b6|1 |0 |0 |0 |0 |
    |paho3709101254858.MQTT_paho|MQTT_paho |0 |0 |9 |0 |9 |
    |queue1 |queue1 |0 |0 |0 |0 |0 |
    sh-4.2$

    Wrapping up

    That's it. I hope this article helps you to quickly set up Red Hat AMQ 7.4 on OpenShift, plus the external secure client using the MQTT protocol. You can also check out this developer blog for setting up Red Hat AMQ 6.3 on OpenShift with the Camel-based Openwire Client using SSL.

    Last updated: January 22, 2024

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • 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

    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