Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 6. Integrate a Camel Application with the AMQ Broker

6.1. Example How to Deploy a Spring Boot Camel A-MQ Quickstart

This tutorial shows how to deploy a quickstart using the A-MQ image.

6.1.1. Prerequisites

  1. Ensure that CDK is installed and OpenShift is running correctly. See Section 3.1, “Prerequisites”.
  2. Ensure that Maven Repositories are configured for fuse, see Section 3.2.1, “Configure Maven Repositories”

6.1.2. Building and Deploying the Quickstart

This example requires a JBoss A-MQ 6 image and deployment template. If you are using CDK 3.1.1+, JBoss A-MQ 6 images and templates should be already installed in the openshift namespace by default.

To build and deploy the A-MQ quickstart, perform the following steps:

  1. In your FIS environment, login as a developer, for example:

    oc login -u developer -p developer
  2. Create a new project amq-quickstart

    oc new-project amq-quickstart
  3. Determine the version of the A-MQ 6 images and templates installed:

    $ oc get template -n openshift

    You should be able to find a template named amqXX-basic, where XX is the version of A-MQ installed in Openshift.

  4. Deploy the A-MQ 6 image in the amq-quickstart namespace (replace XX with the actual version of A-MQ found in previous step):

    $ oc process openshift//amqXX-basic -p APPLICATION_NAME=broker -p MQ_USERNAME=admin -p MQ_PASSWORD=admin -p MQ_QUEUES=test -n amq-quickstart | oc create -f -

    This oc command could fail, if you use an older version of oc. This syntax works with oc versions 3.5.x (based on Kubernetes 1.5.x).

  5. Add role which is needed for discovery of mesh endpoints (through Kubernetes REST API agent).

    $ oc policy add-role-to-user view system:serviceaccount:amq-quickstart:default
  6. Create the quickstart project using the Maven workflow:

    $ mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate \
    -DarchetypeCatalog= \
    -DarchetypeGroupId=org.jboss.fuse.fis.archetypes \
    -DarchetypeArtifactId=spring-boot-camel-amq-archetype \
  7. The archetype plug-in switches to interactive mode to prompt you for the remaining fields:

    $ Define value for property 'groupId': : org.example.fis
      Define value for property 'artifactId': : fis-spring-boot-camel-amq
      Define value for property 'version':  1.0-SNAPSHOT: :
      Define value for property 'package':  org.example.fis: :
      [INFO] Using property: spring-boot-version = 1.4.1.RELEASE
      Confirm properties configuration:
      groupId: org.example.fis
      artifactId: fis-spring-boot
      version: 1.0-SNAPSHOT
      package: org.example.fis
      spring-boot-version: 1.4.1.RELEASE
      Y: :

    When prompted, enter org.example.fis for the groupId value and fis-spring-boot-camel-amq for the artifactId value. Accept the defaults for the remaining fields.

  8. Navigate to the quickstart directory fis-spring-boot-camel-amq:

    $ cd fis-spring-boot-camel-amq
  9. Customize the client credentials for logging on to the broker, by setting the ACTIVEMQ_BROKER_USERNAME and ACTIVEMQ_BROKER_PASSWORD environment variables. In the fis-spring-boot-camel-amq project, edit the src/main/fabric8/deployment.yml file, as follows:

                  cpu: "0.2"
    #              memory: 256Mi
                  cpu: "1.0"
    #              memory: 256Mi
              - name: ACTIVEMQ_SERVICE_NAME
                value: broker-amq-tcp
              - name: ACTIVEMQ_BROKER_USERNAME
                value: admin
              - name: ACTIVEMQ_BROKER_PASSWORD
                value: admin
  10. Run the mvn command to deploy the quickstart to OpenShift server.

    mvn fabric8:deploy
  11. To verify that the quickstart is running successfully, navigate to the OpenShift console, select the project amq-quickstart, click Applications, select Pods, click fis-spring-boot-camel-am-1-xxxxx, and click Logs.
  12. The output shows the messages are sent successfully.

    10:17:59.825 [Camel (camel) thread #10 - timer://order] INFO  generate-order-route - Generating order order1379.xml
    10:17:59.829 [Camel (camel) thread #8 - JmsConsumer[incomingOrders]] INFO  jms-cbr-route - Sending order order1379.xml to the UK
    10:17:59.829 [Camel (camel) thread #8 - JmsConsumer[incomingOrders]] INFO  jms-cbr-route - Done processing order1379.xml
    10:18:02.825 [Camel (camel) thread #10 - timer://order] INFO  generate-order-route - Generating order order1380.xml
    10:18:02.829 [Camel (camel) thread #7 - JmsConsumer[incomingOrders]] INFO  jms-cbr-route - Sending order order1380.xml to another country
    10:18:02.829 [Camel (camel) thread #7 - JmsConsumer[incomingOrders]] INFO jms-cbr-route - Done processing order1380.xml
  13. To view the routes on the web interface, click Open Java Console and check the messages in the A-MQ queue.