Skip to main content
Redhat Developers  Logo
  • 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 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

    • OpenShift AI learning
    • 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.
    • Explore the solution
  • 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

    • Access product downloads to start building and testing right away.
    • 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.
    • Explore the benefits

JBoss A-MQ on OpenShift Cheat Sheet

October 10, 2017
Abdellatif Bouchama
Related topics:
KubernetesMicroservices
Related products:
Red Hat OpenShift Container PlatformStreams for Apache Kafka

    We hear about Microservices a lot nowadays. Its implementation requires us to deal with new challenges. A key question that comes with using microservices is how to handle interactions in an asynchronous way. The answer to that is messaging.

    Among other things, messaging features the following:

    • Loose coupling since it decouples client from services.
    • Improved availability since the message broker buffers messages until the consumer is able to process them.
    • Supports a variety of communication patterns including request/reply, notifications, request/async response, publish/subscribe, publish/async response and more.

    One of the most famous products in messaging is JBoss A-MQ. Among the questions I receive from customers is whether it’s possible to run Red Hat JBoss A-MQ on Red Hat OpenShift. The answer is yes, Red Hat JBoss A-MQ (A-MQ) is available as a containerized image that is designed for use with OpenShift. It allows developers to quickly deploy an A-MQ message broker in a hybrid cloud environment.

    The configuration of the broker can be performed two ways:

    • using the S2I (Source-to-image) tool. A complete example here that you can follow step by step: amq62-basic-s2i.
    • using parameters specified in the A-MQ application template.

    Before we proceed with how to deploy A-MQ on OpenShift, let's take a look at different A-MQ architectures in high availability environment.

    A-MQ in HA (High Availability) environment

    Horizontal Scaling: Load Balancing

    We can get this HA architecture by scaling a pod in persistent or non persistent storage. In the non-persistent mode, all instances don't have a persistentVolumeClaim but they share the same service.

    In persistent mode, all instances share the same service and they have a persistent volume claim bound to the available persistent volume.

    In both modes, the messages will be dispatched to the active consumer and the producers will be distributed across all of the available brokers,  All the brokers will be discovered and automatically networked together in a mesh configuration, the discovery is based on the Kubernetes Service abstraction that you can configure also from the environment variable MESH_SERVICE_NAME. All the pods are in "Running status" and share the load.

    To realize this HA architecture, you only have to specify the parameter "AMQ_SPLIT=true" in the configuration. This will result in the server creating independent split-n directories for each instance within the Persistent Volume which can then be used as their data store. This is now the default setting in all persistent templates.

     

    Vertical Scaling: Master/Slave

    The Master/Slave setup is realized only by setting the parameter “AMQ_SPLIT=false” in the configuration and only in persistent mode.

    The “master” instance gets the file lock and if we scale up, all the new pods will be in “Not Ready” status, and their brokers will be “slave” and polling until the lock is released.

     

     

    Deploy A-MQ on OpenShift

    The rest of this post will be based on A-MQ Application templates, and especially on on amq-persistent-ssl template, since it's the way to access to the broker from external clients via its SSL transports.

    Before we get started, you must create a persistent volume in OpenShfit and it should be in available status.

    Install A-MQ Image Stream:

    To update to the latest xPaaS image run the following steps to pull in the content:

    1. On your master host(s), ensure you are logged into the CLI as a cluster administrator or user that has project administrator access to the global “openshift” project. For example:

    $ oc login -u system:admin

    2. Run the following commands to update the core AMQ OpenShift image stream in the “openshift” project, note that it is normal to see error messages saying some image streams already exist while issuing the create:

    $ oc create -n openshift -f \
     https://raw.githubusercontent.com/jboss-openshift/application-templates/ose-v1.4.5/jboss-image-streams.json
    
    $ oc replace -n openshift -f \
     https://raw.githubusercontent.com/jboss-openshift/application-templates/ose-v1.4.5/jboss-image-streams.json
    
    $ oc -n openshift import-image jboss-amq-62
    $ oc -n openshift import-image jboss-amq-63

    3. Run the following commands to update the AMQ templates:

    $ for template in amq62-basic.json \
     amq62-ssl.json \
     amq63-persistent-ssl.json \
     amq62-persistent.json \
     amq63-basic.json \
     amq63-ssl.json \
     amq62-persistent-ssl.json \
     amq63-persistent.json;
     do
     oc replace -n openshift -f \
     https://raw.githubusercontent.com/jboss-openshift/application-templates/ose-v1.4.5/amq/${template}
     done

     

    Deploy A-MQ:

    You can deploy your A-MQ Broker directly from the Web Console, by using the URL (Adding as suffix /console/create?template=amq63-persistent-ssl):

    e.g;

    https://openshift.amqocp.redhat.com/console/create?template=amq63-persistent-ssl

    Or you can use oc (openshift client):

     oc project amq-demo
     
     echo '{"kind": "ServiceAccount", "apiVersion": "v1", "metadata": {"name": "amq-service-account"}}' | oc create -f -
    
     oc policy add-role-to-user view system:serviceaccount:amq-demo:amq-service-account

    You must create a set of keys to run A-MQ inside of Openshift. If you do not have an enterprise one, you can follow the steps below to create a set of SSL Keys.
    The rest of commands in order to create secret, the amq service account, create the broker and create routes to expose the transport connector to the external clients:

    keytool -genkey -noprompt -trustcacerts -alias broker -keyalg RSA -keystore broker.ks -keypass password -storepass password -dname "cn=Abel, ou=engineering, o=company, c=US"
    keytool -export -noprompt -alias broker -keystore broker.ks -file broker_cert -storepass password
    keytool -genkey -noprompt -trustcacerts -alias client -keyalg RSA -keystore client.ks -keypass password -storepass password -dname "cn=Abel, ou=engineering, o=company, c=US"
    keytool -import -noprompt -trustcacerts -alias broker -keystore client.ts -file broker_cert -storepass password
    
    oc secrets new amq-app-secret broker.ks
    oc secrets add sa/amq-service-account secret/amq-app-secret
    
    oc process amq63-persistent-ssl -p APPLICATION_NAME=amq63 -p MQ_USERNAME=admin -p MQ_PASSWORD=admin -p AMQ_STORAGE_USAGE_LIMIT=1gb -p IMAGE_STREAM_NAMESPACE=openshift -p AMQ_TRUSTSTORE_PASSWORD=password -p AMQ_KEYSTORE_PASSWORD=password -p AMQ_SECRET=amq-app-secret -p AMQ_KEYSTORE=broker.ks -p AMQ_TRUSTSTORE=broker.ks -n amq-demo | oc create -f -
    
    oc create route passthrough --service amq63-amq-tcp-ssl
    oc create route passthrough --service amq63-amq-stomp-ssl
    oc create route passthrough --service amq63-amq-amqp-ssl
    oc create route passthrough --service amq63-amq-mqtt-ssl

    At the end, you should run (watch oc get pods) until the 2 pods were in Running status, like the following:

    [cloud-user@master-0 ~]$ oc get pods
    NAME                    READY     STATUS    RESTARTS   AGE
    amq63-amq-2-m8fdh       1/1       Running   0          2m
    amq63-drainer-1-3rpgx   1/1       Running   0          8m

    From the Web Console, you should see the following:

    NB: If you wonder why 2 pods? and what's the role of this new drainer pod? The answer is here: Chapter 4. Get Started - Red Hat Customer Portal

     

    Client Access to Broker

    Your client needs to use an SSL transport. To configure your local JMS client to talk to the A-MQ broker instance on OpenShift:

    1. Connect to the OpenShift and query the address of the OpenShift route.

    $ oc get routes
     NAME                HOST/PORT                                                                 PATH      SERVICES            PORT      TERMINATION   WILDCARD
     amq63-amq-tcp-ssl   amq63-amq-tcp-ssl-amq-demo.apps.redhat.com             amq63-amq-tcp-ssl   <all>     passthrough   None

    Note the HOST of the route, in this example: amq63-amq-tcp-ssl-amq-demo.apps.redhat.com.

    2. You should copy the three files broker.ks, client.ks and client.ts to your local computer.

    3. Configure your JMS client to use broker URL as obtained from step 1 and use SSL keystore client.ks and trustore client.ts from step 2.

    e.g.

    brokerUrl:

    failover:(ssl://amq63-amq-tcp-ssl-amq-demo.apps.redhat.com:443)

    SSL options:

    -Djavax.net.ssl.keyStore=./client.ks
    
    -Djavax.net.ssl.keyStorePassword=password
    
    -Djavax.net.ssl.trustStore=./client.ts
    
    -Djavax.net.ssl.trustStorePassword=password

     

    That's all !!

    Enjoy ;-)

    Last updated: October 5, 2017

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    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

    Chat Support

    Please log in with your Red Hat account to access chat support.