Installing AMQ Online

You have two options for installing AMQ Online: download and extract the ZIP file with the YAML bundle or you can install the AMQ Online Operator on an OpenShift Container Platform 4.x cluster by using OperatorHub in the OpenShift Container Platform console. In this quick start, we will use the YAML bundle. You can check the Evaluating AMQ Online on OpenShift documentation for further instructions on how to install AMQ Online using OperatorHub.

Download and extract

To download and extract the installation file:

  1. Download the latest version of AMQ Online's Operator Installation and Example Files. The latest version at the time of this writing is Red Hat AMQ Online 1.7.

  2. Unzip AMQ Online installation resources to any destination:

    • On Windows or Mac, extract the contents of the ZIP archive by double-clicking on the ZIP file.

    • On Red Hat Enterprise Linux (RHEL), open a terminal window in the target machine and navigate to where the ZIP file was downloaded. Extract the ZIP file by executing the following command:

      # unzip amq-online-1.7.0-install.zip

  3. Change the current path to the unzipped directory.

    # cd amq-online-1.7.0-install

Install AMQ Online using a YAML bundle

To install AMQ Online using a YAML bundle:

  1. Log into the OpenShift cluster with cluster-admin privileges, for example:

    # oc login -u system:admin

  2. By default, the installation files work in the amq-online-infra namespace. Modify the installation files according to the namespace where you will install AMQ Online, for example messaging:

    • On Linux, use:

      # sed -i 's/amq-online-infra/messaging/' install/bundles/amq-online/*.yaml

    • On Mac:

      # sed -i '' 's/amq-online-infra/messaging/' install/bundles/amq-online/*.yaml

  3. Create the project into which you're deploying AMQ Online, for example messaging:

    # oc new-project messaging

  4. Deploy using the AMQ Online bundle:

    # oc apply -f install/bundles/amq-online

  5. Install the example plans and infrastructure configuration:

    # oc apply -f install/components/example-plans

  6. Install the example roles:

    # oc apply -f install/components/example-roles

  7. Install the standard authentication service:

    # oc apply -f install/components/example-authservices/standard-authservice.yaml

Create an address endpoint

To create an address endpoint, you need to create a messaging address space. In AMQ Online, you create address spaces using standard command-line tools. For example:

  1. Log in as a normal user, like developer:

    # oc login -u developer

    # oc new-project my-app-project

  2. Create a new address space (e.g., my-address-space) definition of type standard with a standard small plan:

    # cat << EOF | oc create -f -
    apiVersion: enmasse.io/v1beta1
    kind: AddressSpace
    metadata:
      name: my-address-space
    spec:
      type: standard
      plan: standard-small
    EOF
  3. Check the status of the address space creation, which should return true when provisioning is done:

    # echo `oc get addressspace my-address-space -o jsonpath='{.status.isReady}'`

    It may take a few moments.

  4. Now that you have an address space, you can create an address definition named my-queue of type queue with a standard-small-queue plan:

    # cat << EOF | oc create -f -
    apiVersion: enmasse.io/v1beta1
    kind: Address
    metadata:
        name: my-address-space.my-queue
    spec:
        address: my-queue
        type: queue
        plan: standard-small-queue
    EOF
  5. Create a messaging user to access the queue with send and receive permissions:

    # cat << EOF | oc create -f -
    apiVersion: user.enmasse.io/v1beta1
    kind: MessagingUser
    metadata:
      name: my-address-space.user1
    spec:
      username: user1
      authentication:
        type: password
        password: cGFzc3dvcmQ= # Base64 encoded
      authorization:
        - addresses: ["my-queue"]
          operations: ["send", "recv"]
    EOF

You are now ready to start sending and receiving messages.

Send and receive messages

Finally, it's time to test sending and receiving messages using an external application. You will need to use Java 8 to run the following sample code.

  1. Clone this git repo to test the access from an application to your new AMQ Online addresses:

    $ git clone https://github.com/hguerrero/amq-examples.git

  2. Switch to the camel-amqp-demo folder:

    $ cd amq-examples/camel-amqp-demo/

  3. As we are using Routes for external access to the cluster, we need the cluster CA certificate to enable TLS in the client. Extract the public certificate of the broker certification authority:

    $ oc get addressspace my-address-space -o jsonpath='{.status.caCert}{"\n"}' | base64 --decode > src/main/resources/ca.crt

  4. Import the trusted cert to a keystore:

    $ keytool -import -trustcacerts -alias root -file src/main/resources/ca.crt -keystore src/main/resources/truststore.ts -storepass password -noprompt

  5. Now you can run the Red Hat Fuse application to send and receive messages to the AMQ Online messaging address endpoint using the following maven command (this command requires Java 8):

    $ mvn -Drun.jvmArguments="-Damq.url=amqps://`oc get addressspace my-address-space -o jsonpath='{.status.endpointStatuses[?(@.name=="messaging")].externalHost}{"\n"}'`:443 -Damq.destination=queue:my-queue" clean package spring-boot:run

    After finishing the clean and package phases, you will see the Spring Boot application start creating a producer and a consumer sending and receiving 100 messages to the “my-queue” AMQ Online queue address:

    14:35:52.607 [CamelMainRunController] INFO  o.a.camel.spring.SpringCamelContext - Apache Camel 2.18.1.redhat-000021 (CamelContext: camel) started in 1.368 seconds
    14:35:57.675 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 1
    14:35:57.842 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 2
    14:35:57.854 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 1
    14:35:57.886 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 2
    14:35:57.890 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 3
    14:35:57.928 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 3
    14:35:57.940 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 4
    14:35:57.971 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 4
    14:35:57.992 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 5
    14:35:58.024 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 5
    14:35:58.044 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 6
    14:35:58.080 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 6
    14:35:58.096 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 7
    14:35:58.130 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 7
    14:35:58.147 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 8
    14:35:58.179 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 8
    14:35:58.198 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 9
    14:35:58.230 [Camel (camel) thread #0 - JmsConsumer[my-queue]] INFO  consumer-route - Message received >>> Message 9
    14:35:58.247 [Camel (camel) thread #1 - timer://foo] INFO  producer-route - Sent Message 10
    

    You’re done! Press Ctrl+C to stop the running program.

Last updated: April 1, 2021

Comments