This quickstart demonstrates how to connect to AMQ Broker and use JMS messaging between two Camel routes.
Important
|
The version of AMQ Broker has to be at least 1.2 |
In this example we will use two containers, one container to run as an AMQ Broker instance, and another as a client to the broker, where the Camel routes are running.
This quickstart requires AMQ Broker to have been deployed and running first. To install AMQ Broker into OpenShift or Kubernetes follow documentation.
Quickstart uses the standard address space and requires standard authentication. For address space and queue definition standard-small-queue, standard_unlimited plans are used, therefore make sure you have also installed example plans, roles and standard authentication service.
Important
|
This quickstart can run in 1 mode: on Kubernetes / OpenShift Cluster. Quickstart requires Java 8 or Java 11 (fuse-karaf-openshift-jdk11-rhel8 image is used to build in Java 11)
|
Important
|
You need to run this example on Container Development Kit 3.3 or OpenShift 3.7. Both of these products have suitable Fuse images pre-installed. If you run it in an environment where those images are not preinstalled follow the steps described in Running the Quickstart on a single-node Kubernetes/OpenShift cluster without preinstalled images. |
A single-node Kubernetes/OpenShift cluster provides you with access to a cloud environment that is similar to a production environment.
If you have a single-node Kubernetes/OpenShift cluster, such as Minishift or the Red Hat Container Development Kit, installed and running, you can deploy your quickstart there.
-
Log in to your OpenShift cluster:
$ oc login -u developer -p developer
-
Create a new OpenShift project for the quickstart:
$ oc new-project MY_PROJECT_NAME
-
Change the directory to the folder that contains the extracted quickstart application (for example,
my_openshift/karaf-camel-amq
) :$ cd my_openshift/karaf-camel-amq
-
Before running the quickstart, you need to configure AMQ Broker (to create user and queue - both as an admin). Run the following commands to apply configuration files:
$ oc login -u system:admin $ oc apply -f src/main/resources/k8s
-
Wait until address space is ready:
$ oc get addressspace karaf-camel-amq -o jsonpath={.status.isReady}
-
Build and deploy the project to the OpenShift cluster:
$ mvn clean -DskipTests oc:deploy -Popenshift
-
In your browser, navigate to the
MY_PROJECT_NAME
project in the OpenShift console. Wait until you can see that the pod for thekaraf-camel-amq
has started up. -
On the project’s
Overview
page, navigate to the details page deployment of thekaraf-camel-amq
application:https://OPENSHIFT_IP_ADDR:8443/console/project/MY_PROJECT_NAME/browse/rc/karaf-camel-amq-NUMBER_OF_DEPLOYMENT?tab=details
. -
Switch to tab
Logs
and then see the messages sent by Camel:
... 2021-03-05 10:12:54,502 | INFO | ile://work/jms/input | file-to-jms-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Receiving order order166.xml 2021-03-05 10:12:54,526 | INFO | umer[incomingOrders] | jms-cbr-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Sending order order166.xml to the UK 2021-03-05 10:12:54,527 | INFO | umer[incomingOrders] | jms-cbr-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Done processing order166.xml 2021-03-05 10:12:59,527 | INFO | ile://work/jms/input | file-to-jms-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Receiving order order167.xml 2021-03-05 10:12:59,556 | INFO | umer[incomingOrders] | jms-cbr-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Sending order order167.xml to the UK 2021-03-05 10:12:59,557 | INFO | umer[incomingOrders] | jms-cbr-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Done processing order167.xml 2021-03-05 10:13:04,558 | INFO | ile://work/jms/input | file-to-jms-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Receiving order order168.xml 2021-03-05 10:13:04,568 | INFO | umer[incomingOrders] | jms-cbr-route | 126 - org.apache.camel.camel-core - 2.23.2.fuse-780036-redhat-00001 | Sending order order168.xml to the US ...
A single-node Kubernetes/OpenShift cluster provides you with access to a cloud environment that is similar to a production environment.
If you have a single-node Kubernetes/OpenShift cluster, such as Minishift or the Red Hat Container Development Kit, installed and running, you can deploy your quickstart there.
-
Log in to your OpenShift cluster:
$ oc login -u developer -p developer
-
Create a new OpenShift project for the quickstart:
$ oc new-project MY_PROJECT_NAME
-
Import base images in your newly created project (MY_PROJECT_NAME) according to documentation.
-
Change the directory to the folder that contains the extracted quickstart application (for example,
my_openshift/karaf-camel-amq
) :$ cd my_openshift/karaf-camel-amq
-
Before running the quickstart, you need to configure AMQ Broker (to create user and queue - both as an admin). Run the following commands to apply configuration files:
$ oc login -u system:admin $ oc apply -f src/main/resources/k8s
-
Wait until address space is ready:
$ oc get addressspace karaf-camel-amq -o jsonpath={.status.isReady}
-
Build and deploy the project to the OpenShift cluster:
$ mvn clean -DskipTests oc:deploy -Popenshift -Djkube.generator.fromMode=istag -Djkube.generator.from=MY_PROJECT_NAME/fuse7-karaf-openshift:1.13
-
In your browser, navigate to the
MY_PROJECT_NAME
project in the OpenShift console. Wait until you can see that the pod for thekaraf-camel-amq
has started up. -
On the project’s
Overview
page, navigate to the details page deployment of thekaraf-camel-amq
application:https://OPENSHIFT_IP_ADDR:8443/console/project/MY_PROJECT_NAME/browse/rc/karaf-camel-amq-NUMBER_OF_DEPLOYMENT?tab=details
. -
Switch to tab
Logs
and then see the messages sent by Camel: