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-jbang-examples.git
The following commit(s) were added to refs/heads/main by this push: new e44e108 Move ftp example here e44e108 is described below commit e44e108c7a9d23b05f63b70dde4c4dc2dd252430 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Dec 3 14:29:28 2024 +0100 Move ftp example here --- ftp/README.adoc | 105 +++++++++++++++++++++++++++++++++++++++++++++ ftp/application.properties | 19 ++++++++ ftp/compose.yaml | 25 +++++++++++ ftp/ftp.camel.yaml | 12 ++++++ ftp/payload.xml | 3 ++ 5 files changed, 164 insertions(+) diff --git a/ftp/README.adoc b/ftp/README.adoc new file mode 100644 index 0000000..34c7ce0 --- /dev/null +++ b/ftp/README.adoc @@ -0,0 +1,105 @@ +== 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 (or Podman) + +[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. + + +=== More Information + +This example was also covered in the following YouTube video: https://youtu.be/V0sBmE8rcVg + + +=== 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/ftp/application.properties b/ftp/application.properties new file mode 100644 index 0000000..73cdd56 --- /dev/null +++ b/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/ftp/compose.yaml b/ftp/compose.yaml new file mode 100644 index 0000000..2348bfb --- /dev/null +++ b/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/ftp/ftp.camel.yaml b/ftp/ftp.camel.yaml new file mode 100644 index 0000000..cc083b3 --- /dev/null +++ b/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/ftp/payload.xml b/ftp/payload.xml new file mode 100644 index 0000000..a087424 --- /dev/null +++ b/ftp/payload.xml @@ -0,0 +1,3 @@ +<order id="123"> + <item id="444">Camel in Action</item> +</order> \ No newline at end of file