You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/06/23 02:17:45 UTC
[camel-k-examples] branch main updated: fix errors and add context to amqp example (#55)
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 1ea2905 fix errors and add context to amqp example (#55)
1ea2905 is described below
commit 1ea29054e6865bb18ec4ffa35acc90d221d1774f
Author: Kuthumi Pepple <ku...@gmail.com>
AuthorDate: Thu Jun 23 03:17:40 2022 +0100
fix errors and add context to amqp example (#55)
---
.../amqp/AmqpConnectionBeanProducer.java | 2 +-
generic-examples/amqp/README.md | 46 +++++++++++++++++++++-
generic-examples/amqp/amqp.groovy | 2 +-
generic-examples/amqp/artemis/README.md | 3 +-
4 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/generic-examples/amqp/AmqpConnectionBeanProducer.java b/generic-examples/amqp/AmqpConnectionBeanProducer.java
index c766426..5b5a7aa 100644
--- a/generic-examples/amqp/AmqpConnectionBeanProducer.java
+++ b/generic-examples/amqp/AmqpConnectionBeanProducer.java
@@ -27,6 +27,6 @@ public class AmqpConnectionBeanProducer extends org.apache.camel.builder.RouteBu
from("timer:foo?period=1000")
.setBody()
.simple("Hello Camel K")
- .to("amqp:queue:example?exchangePattern=InOnly")
+ .to("amqp:queue:example?exchangePattern=InOnly");
}
}
diff --git a/generic-examples/amqp/README.md b/generic-examples/amqp/README.md
index a23983d..4d2b075 100644
--- a/generic-examples/amqp/README.md
+++ b/generic-examples/amqp/README.md
@@ -1,5 +1,47 @@
# AMQP Camel K examples
-Find useful examples about how to use AMQP in a Camel K integration.
+These examples demonstrate how to use AMQP in a Camel K integration.
-You may find useful instructions [how to install a JMS/AMQP Broker on Kubernetes](./artemis/) for demo purposes.
\ No newline at end of file
+You can find more information about Apache Camel and Apache Camel K on the [official Camel website](https://camel.apache.org).
+
+## Before you begin
+
+Read the general instructions in the [root README.md file](/README.md) for setting up your environment and the Kubernetes cluster before looking at this example.
+
+Make sure you've read the [installation instructions](https://camel.apache.org/camel-k/latest/installation/installation.html) for your specific
+cluster before starting the example.
+
+## Additional Requirements for running this example
+
+**An AMQP Broker**: needed MoM for running the examples. For installation instructions, see [how to install a JMS/AMQP Broker on Kubernetes](./artemis/) for demo purposes.
+
+## Understanding the Example
+
+- [`AmqpConnectionBeanProducer.java`](./AmqpConnectionBeanProducer.java) defines a route that generates a message every second and sends it to an amqp queue.
+- [`AmqpConnectionBeanConsumer.java`](./AmqpConnectionBeanConsumer.java) consumes messages from the amqp queue, logs them to the logger using the info level
+- [`amqp.groovy`](./amqp.groovy) generates a message every second and sends to amqp topic
+- [`amqp.properties`](./amqp.properties) holds required credentials to connect to broker.
+
+## Running the Example
+You should have an amqp broker running in a namespace, if not, see [how to install a JMS/AMQP Broker on Kubernetes](./artemis/)
+
+To create a secret for your credentials, run:
+```
+kubectl create secret generic my-amqp --from-file=amqp.properties
+```
+
+To run an integration that sends message to amqp queue, run:
+```
+kamel run AmqpConnectionBeanProducer.java --config secret:my-amqp
+```
+
+To consume messages from the amqp queue, run:
+```
+kamel run AmqpConnectionBeanConsumer.java --dev --config secret:my-amqp
+```
+The terminal should show the logged messages:
+```console
+[1] 2022-06-21 15:44:46,513 INFO [info] (Camel (camel-1) thread #1 - JmsConsumer[example]) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K]
+[1] 2022-06-21 15:44:47,513 INFO [info] (Camel (camel-1) thread #1 - JmsConsumer[example]) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K]
+[1] 2022-06-21 15:44:48,517 INFO [info] (Camel (camel-1) thread #1 - JmsConsumer[example]) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello Camel K]
+```
\ No newline at end of file
diff --git a/generic-examples/amqp/amqp.groovy b/generic-examples/amqp/amqp.groovy
index 73b6320..aebb3fb 100644
--- a/generic-examples/amqp/amqp.groovy
+++ b/generic-examples/amqp/amqp.groovy
@@ -19,7 +19,7 @@
//
// To run this integrations use:
//
-// kamel run -e BROKER_URL=event-bus-amqp-0-svc.messaging.svc.cluster.local -d camel-amqp examples/amqp.groovy
+// kamel run -e BROKER_URL=<service-name>.<namespace>.svc.cluster.local -d camel-amqp amqp.groovy
//
camel {
diff --git a/generic-examples/amqp/artemis/README.md b/generic-examples/amqp/artemis/README.md
index 15db404..565fe87 100644
--- a/generic-examples/amqp/artemis/README.md
+++ b/generic-examples/amqp/artemis/README.md
@@ -4,7 +4,8 @@ This is a very simple example to show how to create a JMS/AMQP broker. **Note**,
## Create a Kubernetes Deployment
-You can [install ActiveMQ Artemis on Kubernetes](https://artemiscloud.io/blog/using_operator/) thanks to ArtemisCloud.io. It would be enough to execute step 1, 2 and 3 of the linked blog post.
+You can [install ActiveMQ Artemis Operator on Kubernetes](https://artemiscloud.io/docs/tutorials/using_operator/) thanks to ArtemisCloud.io. It would be enough to execute steps 1 and 2 of the linked tutorial post. \
+**Note:** Openshift environments may require some adjustments, see [Installing the AMQ Broker Operator](https://access.redhat.com/documentation/en-us/red_hat_amq/7.4/html/deploying_amq_broker_on_openshift_container_platform/broker-operator-broker-ocp#install-broker-operator-broker-ocp)
## Create an AMQP broker instance