Installing AMQ Online

    Download and extract

    1. Download the latest version of Red Hat AMQ Online installation file. The latest version at the time of this writing is Red Hat AMQ Online 1.3.

    2. Unzip Red Hat AMQ Online installation resources to any destination.

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

      • On Red Hat Enterprise Linux, 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-install-1-3.zip

    Install AMQ Online using a YAML bundle

    1. Login in to 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 the 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 where you want to deploy 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 address endpoint

    Create a messaging address space

    In AMQ Online, you create address spaces using standard command-line tools.

    1. Login as normal user, for example:

      # oc login -u developer

      # oc new-project my-app-project

    2. Create a new address space 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 creating, should return true when provisioning is done. It may take a few moments:

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

    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 an 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

    Test using an external application

    1. Clone this git repo to test the access from 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.endpointStatuses[?(@.name=="messaging")].cert}{"\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:

      $ 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 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: December 5, 2019