Este contenido no está disponible en el idioma seleccionado.

Chapter 3. Tutorials


These tutorials follow on from and assume an OpenShift Container Platform 3.9 instance similar to that created in OpenShift Container Platform 3.9 Getting Started.

In this tutorial you prepare and deploy a multiple-node AMQ Broker instance with persistent storage.

3.1. Preparing the AMQ Broker deployment

Procedure

  1. At a command prompt, 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 secrets new amq-app-secret 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 the image and template

Procedure

  1. Navigate to the OpenShift web console and log in, selecting the amq-demo project space.
  2. Click Add to Project > Browse catalog to list all of the default image streams and templates.
  3. Use the Filter search bar to limit the list to those that match amq. You might need to click See all to show the desired application template.
  4. Select a template. This example uses the amq-broker-71-persistence-ssl.yaml template to allow for persistent storage and SSL.

    Expand
    Table 3.1. Example template
    Environment variableValue

    APPLICATION_NAME

    broker

    AMQ_TRANSPORTS

    openwire

    AMQ_USER

    amq-demo-user

    AMQ_PASSWORD

    password

    VOLUME_CAPACITY

    512Mi

    AMQ_KEYSTORE_TRUSTSTORE_DIR

    /etc/amq-secret-volume

    AMQ_TRUSTSTORE

    broker.ts

    AMQ_TRUSTSTORE_PASSWORD

    password

    AMQ_KEYSTORE

    broker.ks

    AMQ_KEYSTORE_PASSWORD

    password

    IMAGE_STREAM_NAMESPACE

    openshift

3.3. Post-deployment

3.3.1. Creating a route

You must create a route for the broker so that clients outside of OpenShift Container Platform can connect using SSL. By default, the OpenWire protocol uses the 61617/TCP port.

Note

Only one broker can be scaled up. You cannot scale up multiple brokers.

Procedure
  1. Click Create a Route and from the Service drop-down menu, click broker-amq-tcp-ssl.
  2. Select the Secure route check box to display the TLS parameters.
  3. From the TLS Termination drop-down menu, click Passthrough. This selection relays all communication to AMQ Broker without the OpenShift router decrypting and resending it.
  4. Clients can now connect to the broker by specifying the following in their configuration:

    factory.setBrokerURL("failover://ssl://broker-amq-demo.example.com:443");

3.3.1.1. Monitoring AMQ Broker

This tutorial demonstrates how to monitor AMQ Broker.

Prerequisite

You must have created a project and a service account, and added the view role to the service account for AMQ Broker deployment. For more information see Preparing the AMQ Broker deployment.

Procedure

  1. At the command line, go to your project:

    $ oc project monitoramq
  2. Deploy a new broker instance to the monitoramq project, using the amq-broker-71-basic template from the openshift namespace:

    $ oc process openshift//amq-broker-71-basic -p APPLICATION_NAME=broker -p AMQ_USER=admin -p AMQ_PASSWORD=admin -p AMQ_QUEUES=TESTQUEUE -n monitoramq | oc create -f -
    
    services "broker-amq-amqp" created
    services "broker-amq-mqtt" created
    services "broker-amq-stomp" created
    services "broker-amq-tcp" created
    deploymentconfigs "broker-amq" created
  3. Get the list of running pods:

    $ oc get pods
    
    NAME                 READY     STATUS    RESTARTS   AGE
    broker-amq-1-ftqmk   1/1       Running   0          14d
  4. Run the oc logs command:

    oc logs -f broker-amq-1-ftqmk
    
    Running /amq-broker-71-openshift image, version 1.3-5
    INFO: Loading '/opt/amq/bin/env'
    INFO: Using java '/usr/lib/jvm/java-1.8.0/bin/java'
    INFO: Starting in foreground, this is just for debugging purposes (stop process by pressing CTRL+C)
    ...
    INFO | Listening for connections at: tcp://broker-amq-1-ftqmk:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600
    INFO | Connector openwire started
    INFO | Starting OpenShift discovery agent for service broker-amq-tcp transport type tcp
    INFO | Network Connector DiscoveryNetworkConnector:NC:BrokerService[broker-amq-1-ftqmk] started
    INFO | Apache ActiveMQ 5.11.0.redhat-621084 (broker-amq-1-ftqmk, ID:broker-amq-1-ftqmk-41433-1491445582960-0:1) started
    INFO | For help or more information please see: http://activemq.apache.org
    WARN | Store limit is 102400 mb (current store usage is 0 mb). The data directory: /opt/amq/data/kahadb only has 9684 mb of usable space - resetting to maximum available disk space: 9684 mb
    WARN | Temporary Store limit is 51200 mb, whilst the temporary data directory: /opt/amq/data/broker-amq-1-ftqmk/tmp_storage only has 9684 mb of usable space - resetting to maximum available 9684 mb.
  5. Run your query to monitor your broker for MaxConsumers:

    $ curl -k -u admin:admin http://console-broker.monitoramq.apps.example.com/console/jolokia/read/org.apache.activemq.artemis:broker=%22broker%22,component=addresses,address=%22TESTQUEUE%22,subcomponent=queues,routing-type=%22anycast%22,queue=%22TESTQUEUE%22/MaxConsumers
    
    {"request":{"mbean":"org.apache.activemq.artemis:address=\"TESTQUEUE\",broker=\"broker\",component=addresses,queue=\"TESTQUEUE\",routing-type=\"anycast\",subcomponent=queues","attribute":"MaxConsumers","type":"read"},"value":-1,"timestamp":1528297825,"status":200}
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2026 Red Hat
Volver arriba