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 2024/06/01 09:03:40 UTC

(camel-kamelets-examples) branch main updated (fac0ed9 -> f644db5)

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 fac0ed9  How to run via docker
     new a00eb0e  Fixed
     new 69eb483  Add SQL example
     new f644db5  Typo

The 3 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/camel-1.0/README.adoc                        |  2 +-
 jbang/prometheus/demo.camel.yaml                   |  5 --
 jbang/sql/README.adoc                              | 83 ++++++++++++++++++++++
 .../user.java => sql/UsingSql.java}                |  6 +-
 jbang/sql/application.properties                   |  4 ++
 jbang/sql/db-init.sql                              |  9 +++
 jbang/sql/docker-compose.yml                       | 17 +++++
 jbang/sql/insert.sql                               |  1 +
 jbang/sql/using-kamelet.camel.yaml                 | 18 +++++
 9 files changed, 135 insertions(+), 10 deletions(-)
 create mode 100644 jbang/sql/README.adoc
 copy jbang/{custom-kamelet/user.java => sql/UsingSql.java} (58%)
 create mode 100644 jbang/sql/application.properties
 create mode 100644 jbang/sql/db-init.sql
 create mode 100644 jbang/sql/docker-compose.yml
 create mode 100644 jbang/sql/insert.sql
 create mode 100644 jbang/sql/using-kamelet.camel.yaml


(camel-kamelets-examples) 02/03: Add SQL 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 69eb4834a55b3076526171aae5212e747f0cfb58
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jun 1 11:03:02 2024 +0200

    Add SQL example
---
 jbang/sql/README.adoc              | 83 ++++++++++++++++++++++++++++++++++++++
 jbang/sql/UsingSql.java            | 10 +++++
 jbang/sql/application.properties   |  4 ++
 jbang/sql/db-init.sql              |  9 +++++
 jbang/sql/docker-compose.yml       | 17 ++++++++
 jbang/sql/insert.sql               |  1 +
 jbang/sql/using-kamelet.camel.yaml | 18 +++++++++
 7 files changed, 142 insertions(+)

diff --git a/jbang/sql/README.adoc b/jbang/sql/README.adoc
new file mode 100644
index 0000000..2a0842e
--- /dev/null
+++ b/jbang/sql/README.adoc
@@ -0,0 +1,83 @@
+== SQL
+
+This example shows how to use a SQL database with Camel.
+
+The example comes with a `docker-compose` file for running a local Postgres database.
+The database is initialized with a `users` table with some sample data.
+
+There are two examples;
+
+- `UsingSql.java` - Java DSL using the SQL component
+- `using-kamelet.camel.yaml` - Yaml DSL using a Postgres Kamelet
+
+There is also a `application.properties` configuration file that setup
+a JDBC `DataSource` for connecting to the database. This configuration file
+is only needed for the `UsingSql.java` example as the Kamelet comes with JDBC driver included.
+
+=== 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
+
+Then run the Postgres database using Docker:
+
+[source,sh]
+----
+$ docker-compose up
+----
+
+And then run Camel:
+
+[source,sh]
+----
+$ camel run using-kamelet.camel.yaml
+----
+
+Or try the Java DSL by:
+
+[source,sh]
+----
+$ camel run UsingSql.java application.properties
+----
+
+When the Camel integration is running, you can insert a new user, from another terminal:
+
+[source,sh]
+----
+$ camel cmd send --endpoint=sql:file:insert.sql --body=empty
+----
+
+And you should see the 3rd user being logged by Camel.
+
+NOTE: To use `camel cmd send` then this requires to have `application.properties` included
+if you run the kamelet example.
+
+
+=== 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/sql/UsingSql.java b/jbang/sql/UsingSql.java
new file mode 100644
index 0000000..6c3015a
--- /dev/null
+++ b/jbang/sql/UsingSql.java
@@ -0,0 +1,10 @@
+import org.apache.camel.builder.RouteBuilder;
+
+public class UsingSql extends RouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        from("sql:select * from users?repeatCount=1")
+            .log("${body}");
+    }
+}
diff --git a/jbang/sql/application.properties b/jbang/sql/application.properties
new file mode 100644
index 0000000..39c4bc9
--- /dev/null
+++ b/jbang/sql/application.properties
@@ -0,0 +1,4 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/test
+spring.datasource.username=postgres
+spring.datasource.password=postgres
+spring.datasource.driverClassName=org.postgresql.Driver
\ No newline at end of file
diff --git a/jbang/sql/db-init.sql b/jbang/sql/db-init.sql
new file mode 100644
index 0000000..62cc9dc
--- /dev/null
+++ b/jbang/sql/db-init.sql
@@ -0,0 +1,9 @@
+DROP TABLE IF EXISTS users;
+CREATE TABLE users(
+  id INT,
+  name VARCHAR(20),
+  byear INT
+);
+
+INSERT INTO users VALUES (1, 'user1', 1995);
+INSERT INTO users VALUES (2, 'user2', 1996);
diff --git a/jbang/sql/docker-compose.yml b/jbang/sql/docker-compose.yml
new file mode 100644
index 0000000..0aed89d
--- /dev/null
+++ b/jbang/sql/docker-compose.yml
@@ -0,0 +1,17 @@
+version: '3.8'
+services:
+  db:
+    image: postgres:14.1-alpine
+    restart: always
+    environment:
+      - POSTGRES_DB=test
+      - POSTGRES_USER=postgres
+      - POSTGRES_PASSWORD=postgres
+    ports:
+      - '5432:5432'
+    volumes: 
+      - db:/var/lib/postgresql/data
+      - ./db-init.sql:/docker-entrypoint-initdb.d/create_tables.sql
+volumes:
+  db:
+    driver: local
\ No newline at end of file
diff --git a/jbang/sql/insert.sql b/jbang/sql/insert.sql
new file mode 100644
index 0000000..2295b27
--- /dev/null
+++ b/jbang/sql/insert.sql
@@ -0,0 +1 @@
+INSERT INTO users VALUES (3, 'user3', 2000);
\ No newline at end of file
diff --git a/jbang/sql/using-kamelet.camel.yaml b/jbang/sql/using-kamelet.camel.yaml
new file mode 100644
index 0000000..56db116
--- /dev/null
+++ b/jbang/sql/using-kamelet.camel.yaml
@@ -0,0 +1,18 @@
+- route:
+    id: route-692e
+    nodePrefixId: route-2cf
+    from:
+      id: from-b8a7
+      uri: kamelet:postgresql-source
+      parameters:
+        serverName: localhost
+        serverPort: 5432
+        username: postgres
+        password: postgres
+        query: select * from users
+        databaseName: test
+        delay: 5000
+      steps:
+        - log:
+            id: log-e4e1
+            message: ${body}


(camel-kamelets-examples) 03/03: Typo

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 f644db591d16cafb3ff988ab6519c88d9df5605c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jun 1 11:03:27 2024 +0200

    Typo
---
 jbang/camel-1.0/README.adoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jbang/camel-1.0/README.adoc b/jbang/camel-1.0/README.adoc
index 6bede73..2f4b587 100644
--- a/jbang/camel-1.0/README.adoc
+++ b/jbang/camel-1.0/README.adoc
@@ -30,7 +30,7 @@ Which allows to run CamelJBang with `camel` as shown below.
 
 === How to run
 
-Then you can run this example (with ActiveMQ broker embeded) using:
+Then you can run this example (with ActiveMQ broker embedded) using:
 
 [source,sh]
 ----


(camel-kamelets-examples) 01/03: Fixed

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 a00eb0e970ab79db0e8904f7fe28362d0453df00
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri May 24 09:53:16 2024 +0200

    Fixed
---
 jbang/prometheus/demo.camel.yaml | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/jbang/prometheus/demo.camel.yaml b/jbang/prometheus/demo.camel.yaml
index 74101b1..21aef8c 100644
--- a/jbang/prometheus/demo.camel.yaml
+++ b/jbang/prometheus/demo.camel.yaml
@@ -15,11 +15,6 @@
                 expression: Hello World
                 id: simple-3fc3
             id: setBody-b8e4
-        - to:
-            uri: direct
-            id: to-280f
-            parameters:
-              name: direct1
 - route:
     nodePrefixId: route-6ce
     id: route-a9b6