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 80922ff Add route template example 80922ff is described below commit 80922ffc2a174359341b9183e29cbf352ab74e6d Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Nov 26 11:42:21 2024 +0100 Add route template example --- jbang/route-template/README.adoc | 70 +++++++++++++++++++++++++++++ jbang/route-template/application.properties | 23 ++++++++++ jbang/route-template/mytemplate.camel.yaml | 33 ++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/jbang/route-template/README.adoc b/jbang/route-template/README.adoc new file mode 100644 index 0000000..8cd677a --- /dev/null +++ b/jbang/route-template/README.adoc @@ -0,0 +1,70 @@ +== Route Template + +This example is using a route template as a skeleton route with configurable parameters. + +Then 2 routes are created that uses the template with actual parameters, +which are configured in `application.properties`. + +This is to demonstrate how to build small _parameterized routes_ and also +use them easily, without any Java coding. + + +=== 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 * +---- + +==== Run in dev mode for hot-reload + +You can run in dev mode, which allows you to edit the source files and hot-reload changes. + +[source,sh] +---- +$ camel run * --dev +---- + +=== Run directly from GitHub + +The example can also be run directly by referring to the GitHub URL as shown: + +[source,sh] +---- +$ camel run https://github.com/apache/camel-kamelets-examples/tree/main/jbang/route-template +---- + + +=== 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/route-template/application.properties b/jbang/route-template/application.properties new file mode 100644 index 0000000..a461bb6 --- /dev/null +++ b/jbang/route-template/application.properties @@ -0,0 +1,23 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- + +camel.route-template[one].template-id=myTemplate +camel.route-template[one].drink=Heineken + +camel.route-template[two].templateId=myTemplate +camel.route-template[two].drink=Cosmopolitan +camel.route-template[two].period=7000 diff --git a/jbang/route-template/mytemplate.camel.yaml b/jbang/route-template/mytemplate.camel.yaml new file mode 100644 index 0000000..ddef7ad --- /dev/null +++ b/jbang/route-template/mytemplate.camel.yaml @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +- routeTemplate: + id: "myTemplate" + parameters: + - name: "drink" + defaultValue: "Bloody Mary" + - name: "period" + defaultValue: 5000 + from: + uri: "timer:tick" + parameters: + period: "{{period}}" + steps: + - setBody: + constant: "You ordered a {{drink}}" + - log: + message: "${body}"