This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
commit 5afae39f3a8ea09329aef43ca05f81bc5261d918 Author: Luca Burgazzoli <[email protected]> AuthorDate: Wed Jun 9 10:37:31 2021 +0200 example: add kamelet discovery example --- .../apache/camel/k/listener/YamlConfigurer.java | 2 + .../kamelets-discovery/data/application.properties | 49 +++++++ .../data/kamelets/filter.kamelet.yaml | 37 +++++ examples/kamelets-discovery/data/routes.yaml | 26 ++++ examples/kamelets-discovery/pom.xml | 155 +++++++++++++++++++++ .../src/main/resources/application.properties | 17 +++ examples/pom.xml | 1 + 7 files changed, 287 insertions(+) diff --git a/camel-k-core/support/src/main/java/org/apache/camel/k/listener/YamlConfigurer.java b/camel-k-core/support/src/main/java/org/apache/camel/k/listener/YamlConfigurer.java index a2f071c..6b918f7 100644 --- a/camel-k-core/support/src/main/java/org/apache/camel/k/listener/YamlConfigurer.java +++ b/camel-k-core/support/src/main/java/org/apache/camel/k/listener/YamlConfigurer.java @@ -50,5 +50,7 @@ public class YamlConfigurer extends AbstractPhaseListener { true); runtime.getCamelContext().getGlobalOptions().put("CamelYamlDslDeserializationMode", getDeserializationMode()); + + LOGGER.info("CamelYamlDslDeserializationMode : {}", runtime.getCamelContext().getGlobalOption("CamelYamlDslDeserializationMode")); } } diff --git a/examples/kamelets-discovery/data/application.properties b/examples/kamelets-discovery/data/application.properties new file mode 100644 index 0000000..0ae23a6 --- /dev/null +++ b/examples/kamelets-discovery/data/application.properties @@ -0,0 +1,49 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + +# +# quarkus +# +quarkus.banner.enabled = false +quarkus.log.level = INFO +quarkus.log.category."org.apache.camel".level = INFO +quarkus.log.category."org.apache.camel.component.kamelet".level = DEBUG + +# +# camel - main +# +camel.main.auto-configuration-log-summary = false +camel.main.name = camel-k +camel.main.stream-caching-enabled = true +camel.main.stream-caching-spool-directory = ${java.io.tmpdir}/camel-k + +# +# camel - kamelets +# +camel.component.kamelet.location = file:{{data.dir}}/kamelets + +# +# camel-k - yaml +# +camel.k.yaml.deserialization-mode = FLOW + +# +# camel-k - sources (routes) +# +camel.k.sources[0].location = file:{{data.dir}}/routes.yaml +camel.k.sources[0].type = source + diff --git a/examples/kamelets-discovery/data/kamelets/filter.kamelet.yaml b/examples/kamelets-discovery/data/kamelets/filter.kamelet.yaml new file mode 100644 index 0000000..d3a091f --- /dev/null +++ b/examples/kamelets-discovery/data/kamelets/filter.kamelet.yaml @@ -0,0 +1,37 @@ +# +# 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. +# + +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: filter + labels: + camel.apache.org/kamelet.type: "action" + annotations: + camel.apache.org/provider: "Apache Software Foundation" +spec: + definition: + title: "Filter" + description: "Filter based on the body" + flow: + from: + uri: "kamelet:source" + steps: + - filter: + simple: "${exchangeProperty.CamelTimerCounter} range '5..10'" + - to: "log:filter" + - to: "kamelet:sink" diff --git a/examples/kamelets-discovery/data/routes.yaml b/examples/kamelets-discovery/data/routes.yaml new file mode 100644 index 0000000..5c0c4f3 --- /dev/null +++ b/examples/kamelets-discovery/data/routes.yaml @@ -0,0 +1,26 @@ +# +# 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. +# + +- from: + uri: "timer:tick" + steps: + - set-body: + exchange-property: "CamelTimerCounter" + - kamelet: + name: "filter/action-0" + - to: + uri: "log:info" \ No newline at end of file diff --git a/examples/kamelets-discovery/pom.xml b/examples/kamelets-discovery/pom.xml new file mode 100644 index 0000000..0b5f7a9 --- /dev/null +++ b/examples/kamelets-discovery/pom.xml @@ -0,0 +1,155 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <parent> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-examples</artifactId> + <version>1.9.0-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>camel-k-runtime-example-kamelets-discovery</artifactId> + + <properties> + <noDeps>true</noDeps> + <quarkus.camel.main.routes-discovery.enabled>false</quarkus.camel.main.routes-discovery.enabled> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-yaml-dsl</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-log</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-timer</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-kamelet</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + <version>${quarkus-version}</version> + </plugin> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <version>${quarkus-version}</version> + <executions> + <execution> + <goals> + <goal>build</goal> + <goal>generate-code</goal> + <goal>generate-code-tests</goal> + </goals> + </execution> + </executions> + <configuration> + <finalName>${project.artifactId}</finalName> + <environmentVariables> + <CAMEL_K_CONF>${project.basedir}/data/application.properties</CAMEL_K_CONF> + <DATA_DIR>${project.basedir}/data</DATA_DIR> + </environmentVariables> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>${exec-maven-plugin-version}</version> + <executions> + <execution> + <goals> + <goal>exec</goal> + </goals> + </execution> + </executions> + <configuration> + <executable>java</executable> + <workingDirectory>${project.basedir}</workingDirectory> + <arguments> + <argument>-jar</argument> + <argument>${project.build.directory}/quarkus-app/quarkus-run.jar</argument> + </arguments> + <environmentVariables> + <CAMEL_K_CONF>${project.basedir}/data/application.properties</CAMEL_K_CONF> + <DATA_DIR>${project.basedir}/data</DATA_DIR> + </environmentVariables> + </configuration> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>native</id> + <activation> + <activeByDefault>false</activeByDefault> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.output-name>${project.artifactId}</quarkus.package.output-name> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>${exec-maven-plugin-version}</version> + <executions> + <execution> + <goals> + <goal>exec</goal> + </goals> + </execution> + </executions> + <configuration> + <executable>${project.build.directory}/${project.artifactId}-runner</executable> + <arguments combine.self="override" /> + <workingDirectory>${project.basedir}</workingDirectory> + <environmentVariables> + <CAMEL_K_CONF>${project.basedir}/data/application.properties</CAMEL_K_CONF> + <DATA_DIR>${project.basedir}/data</DATA_DIR> + </environmentVariables> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> diff --git a/examples/kamelets-discovery/src/main/resources/application.properties b/examples/kamelets-discovery/src/main/resources/application.properties new file mode 100644 index 0000000..d5450b7 --- /dev/null +++ b/examples/kamelets-discovery/src/main/resources/application.properties @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- + diff --git a/examples/pom.xml b/examples/pom.xml index 25443ea..eff7929 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -36,6 +36,7 @@ <module>js</module> <module>yaml</module> <module>kamelets</module> + <module>kamelets-discovery</module> <module>knative</module> <module>kotlin</module> <module>groovy</module>
