Skip to content

Latest commit

 

History

History
95 lines (68 loc) · 2.85 KB

readme.adoc

File metadata and controls

95 lines (68 loc) · 2.85 KB

Camel Example Spring Boot and ActiveMQ AMQP

This example shows how to work with a simple Apache Camel application using Spring Boot and Apache ActiveMQ through the AMQP protocol.

Trying out the example on your local machine

Start the ActiveMQ broker in a docker container:

$ docker run --name amq-broker \
  -e AMQ_USER=admin \
  -e AMQ_PASSWORD=admin \
  -d -p 5672:5672 \
  registry.redhat.io/amq7/amq-broker-rhel8:7.12

How to run the example

You can run this example using

$ mvn spring-boot:run

The application sends messages in SCIENCEQUEUE queue using a timer, and consume the messages from the same queue

In the application log, you will see the following lines:

...
[3 - timer://bar] timer-consumer-route                     : Message sent from route timer-consumer-route to SCIENCEQUEUE
...
[r[SCIENCEQUEUE]] MyLogger                                 : Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello from Camel]

Trying out the example on OpenShift

First, start with creating a new OpenShift project:

$ oc new-project csb-example-amqp

Deploy the AMQ Broker using operator, installing the operator in the current namespace doc and running the following command with the oc client doc :

$ cat << EOF| oc apply -f -
apiVersion: broker.amq.io/v1beta1
kind: ActiveMQArtemis
metadata:
  name: ex-aao
  namespace: csb-example-amqp
spec:
  deploymentPlan:
    image: placeholder
    requireLogin: true
    size: 1
  adminPassword: admin
  adminUser: admin
  acceptors:
    - name: amqp
      expose: true
      protocols: "AMQP"
      port: 5672
EOF

How to run

The application is deployed using the openshift-maven-plugin that takes care of creating all the necessary OpenShift resources.

Simply use the following command to deploy the application:

$ mvn clean package -Popenshift

After the application pod reaches the Ready state, you can try the same steps as in the local machine deployment.

To view the application logs, use oc logs dc/camel-example-spring-boot-amqp

Using Camel components

Apache Camel provides 200+ components which you can use to integrate and route messages between many systems and data formats. To use any of these Camel components, add the component as a dependency to your project.

Help and contributions

If you hit any problem using Camel or have some feedback, then please let us know.

We also love contributors, so get involved :-)

The Camel riders!