You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/04/14 07:56:41 UTC

[camel-kamelets-examples] branch main updated (2e878db -> 5dccb2d)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git


    from 2e878db  Update the documentation for kafka-mq example, since camel-kamelets 3.20.2 has been released
     new 819e54f  MQTT example
     new 5dccb2d  MQTT example

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 jbang/mqtt/README.adoc                | 91 +++++++++++++++++++++++++++++++++++
 jbang/mqtt/conf/mosquitto.conf        |  4 ++
 jbang/mqtt/docker-compose.yml         | 10 ++++
 jbang/mqtt/mqtt.yaml                  | 13 +++++
 jbang/mqtt/payload.json               |  3 ++
 jbang/{kafka-health => mqtt}/start.sh |  2 +-
 6 files changed, 122 insertions(+), 1 deletion(-)
 create mode 100644 jbang/mqtt/README.adoc
 create mode 100644 jbang/mqtt/conf/mosquitto.conf
 create mode 100644 jbang/mqtt/docker-compose.yml
 create mode 100644 jbang/mqtt/mqtt.yaml
 create mode 100644 jbang/mqtt/payload.json
 copy jbang/{kafka-health => mqtt}/start.sh (84%)


[camel-kamelets-examples] 02/02: MQTT example

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git

commit 5dccb2d8a632bb58eee2357905b0628fcdd8c7ec
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Apr 14 09:56:28 2023 +0200

    MQTT example
---
 jbang/mqtt/README.adoc | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/jbang/mqtt/README.adoc b/jbang/mqtt/README.adoc
index 99a4451..2cce6fc 100644
--- a/jbang/mqtt/README.adoc
+++ b/jbang/mqtt/README.adoc
@@ -28,15 +28,14 @@ Which allows to run CamelJBang with `camel` as shown below.
 
 You need to run a MQTT broker such as via Docker, or download and run Apache ActiveMQ Artemis.
 
-To use docker, run the following command
+To use docker (docker compose), run the following command:
 
 [source,sh]
 ----
-docker run -it -p 1883:1883 -p 9001:9001 eclipse-mosquitto
+/start.sh
 ----
 
-
-Then you can run this example using:
+Then you can run the Camel integration using:
 
 [source,sh]
 ----
@@ -64,6 +63,22 @@ The Camel integration will then consume the payload and output in the console.
 2023-04-14 08:58:58.676  INFO 62348 --- [calCliConnector] mqtt.yaml:13                        : The temperature is 21
 ----
 
+==== Stopping
+
+To stop Docker, you can run
+
+[source,sh]
+----
+$ docker-compose down
+----
+
+And you can stop Camel with
+
+[source,sh]
+----
+$ camel stop mqtt
+----
+
 
 === Help and contributions
 


[camel-kamelets-examples] 01/02: MQTT example

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets-examples.git

commit 819e54f6df820bfb5e7bae11b8c05cf02334b412
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Apr 14 09:54:45 2023 +0200

    MQTT example
---
 jbang/mqtt/README.adoc         | 76 ++++++++++++++++++++++++++++++++++++++++++
 jbang/mqtt/conf/mosquitto.conf |  4 +++
 jbang/mqtt/docker-compose.yml  | 10 ++++++
 jbang/mqtt/mqtt.yaml           | 13 ++++++++
 jbang/mqtt/payload.json        |  3 ++
 jbang/mqtt/start.sh            |  7 ++++
 6 files changed, 113 insertions(+)

diff --git a/jbang/mqtt/README.adoc b/jbang/mqtt/README.adoc
new file mode 100644
index 0000000..99a4451
--- /dev/null
+++ b/jbang/mqtt/README.adoc
@@ -0,0 +1,76 @@
+== MQTT
+
+This example is using Camel to receive MQTT events from an external MQTT broker.
+
+=== Install JBang
+
+First install JBang according to https://www.jbang.dev
+
+When JBang is installed then you should be able to run from a shell:
+
+[source,sh]
+----
+$ jbang --version
+----
+
+This will output the version of JBang.
+
+To run this example you can either install Camel on JBang via:
+
+[source,sh]
+----
+$ jbang app install camel@apache/camel
+----
+
+Which allows to run CamelJBang with `camel` as shown below.
+
+=== How to run
+
+You need to run a MQTT broker such as via Docker, or download and run Apache ActiveMQ Artemis.
+
+To use docker, run the following command
+
+[source,sh]
+----
+docker run -it -p 1883:1883 -p 9001:9001 eclipse-mosquitto
+----
+
+
+Then you can run this example using:
+
+[source,sh]
+----
+$ camel run mqtt.yaml
+----
+
+And then from another terminal (or run the integraiton with `--background` option),
+then send a message to the MQTT broker. This can be done with the help from camel-jbang
+where you can send a message as follows:
+
+[source,sh]
+----
+$ camel cmd send --body=file:payload.json mqtt
+----
+
+This will send a message where the payload (body) is read from the local file named payload.json.
+The message is sent to an existing running Camel integration (named mqtt). Then Camel will
+then send the message to the MQTT broker. So in other words we use Camel as a proxy to send the
+message to the actual MQTT broker.
+
+The Camel integration will then consume the payload and output in the console.
+
+[source,text]
+----
+2023-04-14 08:58:58.676  INFO 62348 --- [calCliConnector] mqtt.yaml:13                        : The temperature is 21
+----
+
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/community/support/[let us know].
+
+We also love contributors, so
+https://camel.apache.org/community/contributing/[get involved] :-)
+
+The Camel riders!
diff --git a/jbang/mqtt/conf/mosquitto.conf b/jbang/mqtt/conf/mosquitto.conf
new file mode 100644
index 0000000..6d3b993
--- /dev/null
+++ b/jbang/mqtt/conf/mosquitto.conf
@@ -0,0 +1,4 @@
+protocol mqtt
+listener 1883
+allow_anonymous true
+socket_domain ipv4
\ No newline at end of file
diff --git a/jbang/mqtt/docker-compose.yml b/jbang/mqtt/docker-compose.yml
new file mode 100644
index 0000000..b228e18
--- /dev/null
+++ b/jbang/mqtt/docker-compose.yml
@@ -0,0 +1,10 @@
+version: '3.8'
+services:
+  mosquitto:
+    image: eclipse-mosquitto
+    ports:
+      - '1883:1883'
+    volumes:
+      - ./conf:/mosquitto/config
+      - ./data:/mosquitto/data
+      - ./log:/mosquitto/log
diff --git a/jbang/mqtt/mqtt.yaml b/jbang/mqtt/mqtt.yaml
new file mode 100644
index 0000000..ca32e98
--- /dev/null
+++ b/jbang/mqtt/mqtt.yaml
@@ -0,0 +1,13 @@
+- route:
+    from:
+      uri: kamelet:mqtt5-source
+      parameters:
+        topic: temperature
+        brokerUrl: tcp://localhost:1883
+      steps:
+        - transform:
+            expression:
+              jq:
+                expression: .value
+        - log:
+            message: The temperature is ${body}
diff --git a/jbang/mqtt/payload.json b/jbang/mqtt/payload.json
new file mode 100644
index 0000000..f650d2f
--- /dev/null
+++ b/jbang/mqtt/payload.json
@@ -0,0 +1,3 @@
+{
+  "value": 21
+}
\ No newline at end of file
diff --git a/jbang/mqtt/start.sh b/jbang/mqtt/start.sh
new file mode 100755
index 0000000..d36bb62
--- /dev/null
+++ b/jbang/mqtt/start.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+docker-compose down
+docker rm -f $(docker ps -a -q)
+docker volume rm $(docker volume ls -q)
+docker-compose up -d
+docker-compose logs -f%
\ No newline at end of file