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/09/12 07:49:18 UTC
(camel-kamelets-examples) branch main updated: FTP example
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
The following commit(s) were added to refs/heads/main by this push:
new 7bcd750 FTP example
7bcd750 is described below
commit 7bcd75066853cd865a97600cf1bdf451d5af434c
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Sep 12 09:49:09 2024 +0200
FTP example
---
jbang/ftp/README.adoc | 100 +++++++++++++++++++++++++++++++++++++++
jbang/ftp/application.properties | 19 ++++++++
jbang/ftp/compose.yaml | 25 ++++++++++
jbang/ftp/ftp.camel.yaml | 12 +++++
jbang/ftp/payload.xml | 3 ++
5 files changed, 159 insertions(+)
diff --git a/jbang/ftp/README.adoc b/jbang/ftp/README.adoc
new file mode 100644
index 0000000..5d38908
--- /dev/null
+++ b/jbang/ftp/README.adoc
@@ -0,0 +1,100 @@
+== ActiveMQ to FTP
+
+This example shows how to integrate ActiveMQ with FTP server.
+
+=== Running ActiveMQ and FTP server
+
+You need both an ActiveMQ Artemis broker, and FTP server up and running.
+
+You can run both via Docker Compose
+
+[source,sh]
+----
+$ docker compose up --detach
+----
+
+=== 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 you can run this example using:
+
+[source,sh]
+----
+$ camel run *
+----
+
+=== Sending Messages to ActiveMQ
+
+When the example is running, you need to trigger Camel, by sending messages to the ActiveMQ broker.
+You can either do this via the broker web console http://localhost:8161 (login with `artemis/artemis`
+or by using Camel JBang:
+
+[source,sh]
+----
+$ camel cmd send --body=file:payload.xml
+----
+
+=== Browsing FTP server
+
+When you have send some messages to ActiveMQ then Camel will route these to the FTP server.
+To see which files has been uploaded, you can remote shell into Docker or use Camel JBang:
+
+[source,sh]
+----
+$ camel cmd browse
+----
+
+Which shows a status page of pending messages in the systems.
+
+To see the content of these messages, you can tell Camel to dump via
+
+[source,sh]
+----
+$ camel cmd browse --dump
+----
+
+TIP: To see more options use `camel cmd browse --help`.
+
+
+=== Developer Web Console
+
+You can enable the developer console via `--console` flag as show:
+
+[source,sh]
+----
+$ camel run * --console
+----
+
+Then you can browse: http://localhost:8080/q/dev to introspect the running Camel Application.
+
+
+=== 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/ftp/application.properties b/jbang/ftp/application.properties
new file mode 100644
index 0000000..73cdd56
--- /dev/null
+++ b/jbang/ftp/application.properties
@@ -0,0 +1,19 @@
+# artemis connection factory
+camel.beans.artemisCF = #class:org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory
+# URL for broker
+camel.beans.artemisCF.brokerURL = tcp://localhost:61616
+
+# if broker requires specific login
+camel.beans.artemisCF.user = artemis
+camel.beans.artemisCF.password = artemis
+
+# pooled connection factory
+camel.beans.poolCF = #class:org.messaginghub.pooled.jms.JmsPoolConnectionFactory
+camel.beans.poolCF.connectionFactory = #bean:artemisCF
+camel.beans.poolCF.maxSessionsPerConnection = 500
+camel.beans.poolCF.connectionIdleTimeout = 20000
+# more options can be configured
+# https://github.com/messaginghub/pooled-jms/blob/main/pooled-jms-docs/Configuration.md
+
+# setup JMS component to use connection factory
+camel.component.jms.connection-factory = #bean:poolCF
diff --git a/jbang/ftp/compose.yaml b/jbang/ftp/compose.yaml
new file mode 100644
index 0000000..2348bfb
--- /dev/null
+++ b/jbang/ftp/compose.yaml
@@ -0,0 +1,25 @@
+services:
+
+ artemis:
+ container_name: my-artemis
+ image: apache/activemq-artemis:2.37.0
+ ports:
+ - "8161:8161"
+ - "61616:61616"
+ - "5672:5672"
+ environment:
+ ARTEMIS_USER: artemis
+ ARTEMIS_PASSWORD: artemis
+ ANONYMOUS_LOGIN: false
+
+ ftp-server:
+ container_name: my-ftp-server
+ environment:
+ - FTP_PASS=mypassword
+ - FTP_USER=myuser
+ image: garethflowers/ftp-server
+ ports:
+ - '20-21:20-21/tcp'
+ - '40000-40009:40000-40009/tcp' # Only needed for passive mode
+# volumes:
+# - '/data:/home/user'
diff --git a/jbang/ftp/ftp.camel.yaml b/jbang/ftp/ftp.camel.yaml
new file mode 100644
index 0000000..cc083b3
--- /dev/null
+++ b/jbang/ftp/ftp.camel.yaml
@@ -0,0 +1,12 @@
+- from:
+ uri: "jms:cheese"
+ steps:
+ - log: "Incoming: ${body}"
+ - to:
+ uri: ftp
+ parameters:
+ host: localhost
+ port: 21
+ username: myuser
+ password: mypassword
+ passiveMode: true
\ No newline at end of file
diff --git a/jbang/ftp/payload.xml b/jbang/ftp/payload.xml
new file mode 100644
index 0000000..a087424
--- /dev/null
+++ b/jbang/ftp/payload.xml
@@ -0,0 +1,3 @@
+<order id="123">
+ <item id="444">Camel in Action</item>
+</order>
\ No newline at end of file