This example demonstrates the widget and gadget example from EIP book, running on Spring Boot.
The example with a similar setup (e.g. without Artemis) can be found in this illustration here:
Before the application can run, AtiveMQ Artemis Broker must be started. This can be done with docker, executing the following command:
docker run --name artemis \
-e AMQ_USER=admin \
-e AMQ_PASSWORD=admin \
-d -p 5672:5672 \
quay.io/artemiscloud/activemq-artemis-broker
The port can be configured as desired, but do not forget to match the configured port number in your application.properties
-file!
You can run this example with Maven using:
$ mvn spring-boot:run
In the console you can observe the following log:
2023-07-14T12:03:11.621+02:00 INFO 43233 --- [ main] sample.camel.WidgetGadgetApp : Started WidgetGadgetApp in 2.884 seconds (process running for 3.164) 2023-07-14T12:03:12.644+02:00 INFO 43233 --- [localhost:5672]] org.apache.qpid.jms.JmsConnection : Connection ID:5643b375-0724-4b08-afdf-fe0fc479005a:2 connected to server: amqp://localhost:5672 2023-07-14T12:03:12.717+02:00 INFO 43233 --- [localhost:5672]] org.apache.qpid.jms.JmsConnection : Connection ID:0a66a3f7-2d69-46da-b051-3dc05ef6a1e9:3 connected to server: amqp://localhost:5672 2023-07-14T12:03:12.728+02:00 INFO 43233 --- [localhost:5672]] org.apache.qpid.jms.JmsConnection : Connection ID:4d089c1f-0746-42c1-8721-8225b279c510:4 connected to server: amqp://localhost:5672 2023-07-14T12:03:12.742+02:00 INFO 43233 --- [er[order.queue]] widget : Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: { "__comment__": "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", "order" : { "customerId": "123", "product": "widget", "amount": "2" }}] 2023-07-14T12:03:12.751+02:00 INFO 43233 --- [localhost:5672]] org.apache.qpid.jms.JmsConnection : Connection ID:aaf9f670-0f51-4aed-9b39-1aa08f22e44c:5 connected to server: amqp://localhost:5672 2023-07-14T12:03:12.774+02:00 INFO 43233 --- [localhost:5672]] org.apache.qpid.jms.JmsConnection : Connection ID:f8c079d5-12cd-496c-9951-802fdf34141a:6 connected to server: amqp://localhost:5672 2023-07-14T12:03:12.776+02:00 INFO 43233 --- [er[order.queue]] gadget : Exchange[ExchangePattern: InOnly, BodyType: byte[], Body: { "__comment__": "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.", "order" : { "customerId": "456", "product": "gadget", "amount": "3" }}] 2023-07-14T12:03:12.785+02:00 INFO 43233 --- [localhost:5672]] org.apache.qpid.jms.JmsConnection : Connection ID:4e61d6d5-6535-41a8-b52b-7085324560de:7 connected to server: amqp://localhost:5672
Moreover you can login to the Artemis console with the default username and password, admin/admin and check that there is one message in each of the following queues, widget.queue and gadget.queue
First, start with creating a new OpenShift project:
oc new-project csb-example-amqp
Start a new deployment for Artemis:
oc new-app quay.io/artemiscloud/activemq-artemis-broker -e AMQ_USER=admin -e AMQ_PASSWORD=admin
Patch the default activemq-artemis-broker
service to serve the 5672
port:
oc patch service/activemq-artemis-broker -p '{"spec":{"ports":[{"name":"5672-tcp", "port": 5672, "protocol": "TCP", "targetPort": 5672}]}}'
And run the example with the openshift profile:
mvn clean package -Popenshift
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!