Chapter 3. Deploying AMQ Broker on OpenShift Container Platform


The procedures in this section show how to prepare a broker deployment and an example of using the OpenShift Container Platform web console to deploy a basic broker instance. For examples of deploying other broker configurations, see Tutorials.

Note

The following procedures assume that the broker image and application templates you installed in Installing AMQ Broker on OpenShift Container Platform are available in the global openshift project. If you installed the image and application templates in a specific project namespace, then continue to use that project instead of creating a new project such as amq-demo.

3.1. Preparing an AMQ Broker deployment

Procedure

  1. Use the command prompt to create a new project:

    $ oc new-project amq-demo
  2. Create a service account to be used for the AMQ Broker deployment:

    $ echo '{"kind": "ServiceAccount", "apiVersion": "v1", "metadata": {"name": "amq-service-account"}}' | oc create -f -
  3. Add the view role to the service account. The view role enables the service account to view all the resources in the amq-demo namespace, which is necessary for managing the cluster when using the OpenShift dns-ping protocol for discovering the mesh endpoints.

    $ oc policy add-role-to-user view system:serviceaccount:amq-demo:amq-service-account
  4. AMQ Broker requires a broker keystore, a client keystore, and a client truststore that includes the broker keystore. This example uses Java Keytool, a package included with the Java Development Kit, to generate dummy credentials for use with the AMQ Broker installation.

    1. Generate a self-signed certificate for the broker keystore:

      $ keytool -genkey -alias broker -keyalg RSA -keystore broker.ks
    2. Export the certificate so that it can be shared with clients:

      $ keytool -export -alias broker -keystore broker.ks -file broker_cert
    3. Generate a self-signed certificate for the client keystore:

      $ keytool -genkey -alias client -keyalg RSA -keystore client.ks
    4. Create a client truststore that imports the broker certificate:

      $ keytool -import -alias broker -keystore client.ts -file broker_cert
    5. Use the broker keystore file to create the AMQ Broker secret:

      $ oc create secret generic amq-app-secret --from-file=broker.ks
    6. Add the secret to the service account created earlier:

      $ oc secrets add sa/amq-service-account secret/amq-app-secret

3.2. Deploying a basic broker

Deploy a basic broker that is ephemeral and does not support SSL. This tutorial covers how to create transports, addresses, and queues.

Note

This broker does not support SSL and is not accessible to external clients. Only clients running internally on the OpenShift cluster can connect to the broker. For examples of creating broker configurations that support SSL, see Tutorials.

Prequisites

3.2.1. Deploy the image and template

Procedure

  1. Navigate to the OpenShift web console and log in.
  2. Select the amq-demo project space, or another, existing project in which you want to deploy a broker.
  3. Click Add to Project > Browse Catalog to list all of the default image streams and templates.
  4. Use the Filter search bar to find results that match amq. You might need to click See all to show the desired application template.
  5. Select the amq-broker-73-basic template, which is labeled Red Hat AMQ Broker 7.3 (Ephemeral, no SSL).
  6. Set the following environment variables in the configuration and click Create.

    Expand
    Table 3.1. Example template
    Environment variableDisplay NameValueDescription

    AMQ_PROTOCOL

    AMQ Protocols

    openwire,amqp,stomp,mqtt,hornetq

    The protocols to be accepted by the broker

    AMQ_QUEUES

    Queues

    demoQueue

    Creates an anycast queue called demoQueue

    AMQ_ADDRESSES

    Addresses

    demoTopic

    Creates a multicast address (or topic) called demoTopic

    AMQ_USER

    AMQ Username

    amq-demo-user

    The username the client uses

    AMQ_PASSWORD

    AMQ Password

    password

    The password the client uses with the username

    You can also deploy the image from the command line:

    $ oc new-app --template=amq-broker-73-basic \
       -e AMQ_PROTOCOL=openwire,amqp,stomp,mqtt,hornetq \
       -e AMQ_QUEUES=demoQueue \
       -e AMQ_ADDRESSES=demoTopic \
       -e AMQ_USER=amq-demo-user \
       -e ADMIN_PASSWORD=password \

3.2.2. Deploy the application

After the application is created, you need to deploy it. Deploying the application creates a pod and starts the broker.

Procedure

  1. After the deployment has been created, choose Deployments from the Applications menu.
  2. Click the broker-amq deployment.
  3. Click Deploy to deploy the application.

    Note

    If the application does not deploy, you can check the configuration by clicking the Events tab. If something is incorrect, edit the configuration by clicking the Action button.

  4. After the deployment has appeared on the list, click on it to view the state of the pods. Click on the pod and then click the Logs tab to view the broker logs and verify its state. You should see the queue previously created.
  5. Click the Terminal tab to access a shell where you can use the CLI to test sending and consuming messages.

    sh-4.2$ ./broker/bin/artemis producer
    Producer ActiveMQQueue[TEST], thread=0 Started to calculate elapsed time ...
    
    Producer ActiveMQQueue[TEST], thread=0 Produced: 1000 messages
    Producer ActiveMQQueue[TEST], thread=0 Elapsed time in second : 4 s
    Producer ActiveMQQueue[TEST], thread=0 Elapsed time in milli second : 4584 milli seconds
    sh-4.2$ ./broker/bin/artemis consumer
    Consumer:: filter = null
    Consumer ActiveMQQueue[TEST], thread=0 wait until 1000 messages are consumed
    Received 1000
    Consumer ActiveMQQueue[TEST], thread=0 Consumed: 1000 messages
    Consumer ActiveMQQueue[TEST], thread=0 Consumer thread finished

    You can also use the OpenShift client to access the shell by using the pod name, as shown in the following example.

    oc rsh broker-amq-1-9x89r
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top