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-spring-boot-examples.git
The following commit(s) were added to refs/heads/main by this push: new 6653f05 CAMEL-21573 Replace jetty and undertow for platform-http and http starters (#157) 6653f05 is described below commit 6653f0534650230b56e3b826e0244bff1fae0255 Author: Claudio Miranda <clau...@redhat.com> AuthorDate: Tue May 27 08:47:06 2025 -0300 CAMEL-21573 Replace jetty and undertow for platform-http and http starters (#157) * observation: replaced jetty/undertow for platform-http/http components as the former were deprecated in csb Containers are an integral part of the example Updated configuration, micrometer version * saga: replaced undertow for platform-http components as the former was deprecated in csb * soap-cxf: replaced undertow for platform-http * spring-jdbc: removed undertow and let the default from SB * resilience4j: replaced jetty for platform-http component and fixed logging * platform-http: updated readme with accurate output * http-ssl: add deprecation note about camel-undertow-starter * Deprecation of undertow csb starter --- .../src/main/java/sample/camel/MyRouteBuilder.java | 2 +- http-ssl/README.adoc | 2 + observation/README.adoc | 22 +++- observation/client/pom.xml | 113 +------------------ .../src/main/java/sample/camel/ClientRoute.java | 2 +- .../src/main/resources/application.properties | 2 +- .../client/src/main/resources/log4j2.properties | 25 ----- observation/client/src/main/resources/logback.xml | 33 ++++++ observation/containers/docker-compose.yml | 10 +- observation/loggingtracer/pom.xml | 27 +---- observation/pom.xml | 97 ++++++++++++++++ observation/service1/pom.xml | 112 +------------------ .../src/main/java/sample/camel/Service1Route.java | 2 +- .../src/main/resources/application.properties | 6 +- .../service1/src/main/resources/logback.xml | 33 ++++++ observation/service2/pom.xml | 122 +-------------------- .../src/main/java/sample/camel/Service2Route.java | 2 +- .../src/main/resources/application.properties | 4 +- .../service2/src/main/resources/log4j2.properties | 25 ----- .../service2/src/main/resources/logback.xml | 33 ++++++ platform-http/README.adoc | 62 ++++++----- resilience4j/README.adoc | 14 +-- .../src/main/java/sample/camel/ClientRoute.java | 2 +- resilience4j/client2/pom.xml | 11 +- .../src/main/java/sample/camel/Client2Route.java | 2 +- resilience4j/pom.xml | 1 + resilience4j/service1/pom.xml | 5 +- .../src/main/java/sample/camel/Service1Route.java | 2 +- .../src/main/resources/application.properties | 4 +- resilience4j/service2/pom.xml | 12 +- .../src/main/java/sample/camel/Service2Route.java | 2 +- .../src/main/resources/application.properties | 8 +- .../service2/src/main/resources/log4j2.properties | 2 - saga/local-resources/compose.yaml | 2 +- saga/ocp-resources/amq-broker-ephemeral.yaml | 2 +- saga/pom.xml | 91 +++++++++++---- saga/run-local.sh | 12 +- saga/saga-app/pom.xml | 64 ----------- saga/saga-app/src/main/resources/application.yml | 3 +- saga/saga-flight-service/pom.xml | 64 ----------- .../src/main/resources/application.yml | 3 +- saga/saga-payment-service/pom.xml | 64 ----------- .../src/main/resources/application.yml | 3 +- saga/saga-train-service/pom.xml | 64 ----------- .../src/main/resources/application.yml | 3 +- soap-cxf/pom.xml | 33 +----- .../java/sample/camel/UndertowConfiguration.java | 53 --------- soap-cxf/src/main/resources/application.properties | 2 + .../src/test/java/sample/camel/PojoClientTest.java | 2 +- .../src/test/java/sample/camel/WsdlClientTest.java | 54 ++++----- spring-jdbc/pom.xml | 12 -- spring-jdbc/readme.adoc | 4 +- 52 files changed, 432 insertions(+), 904 deletions(-) diff --git a/actuator-http-metrics/src/main/java/sample/camel/MyRouteBuilder.java b/actuator-http-metrics/src/main/java/sample/camel/MyRouteBuilder.java index adb47e8..df91c18 100644 --- a/actuator-http-metrics/src/main/java/sample/camel/MyRouteBuilder.java +++ b/actuator-http-metrics/src/main/java/sample/camel/MyRouteBuilder.java @@ -26,7 +26,7 @@ public class MyRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { - // First, we have to configure our jetty component, which will be the rest + // First, we have to configure our rest component, which will be // in charge of querying the REST endpoints from actuator restConfiguration() .host("0.0.0.0") diff --git a/http-ssl/README.adoc b/http-ssl/README.adoc index 47ec73d..ae0ce3b 100644 --- a/http-ssl/README.adoc +++ b/http-ssl/README.adoc @@ -8,6 +8,8 @@ This example shows how to configure SSL in different scenarios: 2. two ways SSL, the server and the client check both certificates in a mutual trusted handshake 3. same scenario as point 1 but the server configuration is managed directly in Camel (undertow component) instead of Spring Boot +NOTE: The camel-undertow-starter is deprecated in camel-spring-boot, it's recommended to use the security settings managed by Spring Boot as show in the 1st example. + === Prerequisites keytool installed and available on PATH diff --git a/observation/README.adoc b/observation/README.adoc index 1dfc48e..29a3778 100644 --- a/observation/README.adoc +++ b/observation/README.adoc @@ -25,6 +25,19 @@ You will need to compile this example first: $ mvn compile ---- +=== Run the container services + +[source,sh] +---- +$ docker compose -f containers/docker-compose.yml up +---- + +Then you can access the services with the following urls: + +Zipkin : http://localhost:9411/zipkin/ +Prometheus: http://localhost:9090/ +Grafana : http://localhost:3000/ + === Run the example Then using three different shells and run service1 and service2 before @@ -33,24 +46,21 @@ indicate that the service should be traced. [source,sh] ---- -$ cd service1 -$ mvn compile spring-boot:run +$ mvn -f service2/ compile spring-boot:run ---- When service1 is ready then start service2 [source,sh] ---- -$ cd service2 -$ mvn compile spring-boot:run +$ mvn -f service1/ compile spring-boot:run ---- And then start the client that calls service1 every 30 seconds. [source,sh] ---- -$ cd client -$ mvn compile spring-boot:run +$ mvn -f client/ compile spring-boot:run ---- The client application explicitly instantiates and initializes the diff --git a/observation/client/pom.xml b/observation/client/pom.xml index dc7814e..0fc2b83 100644 --- a/observation/client/pom.xml +++ b/observation/client/pom.xml @@ -32,124 +32,13 @@ <description>An example showing how to trace incoming and outgoing messages from Camel with Micrometer Observation </description> - <properties> - <brave.version>5.15.0</brave.version> - </properties> - - <!-- import Camel BOM --> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>io.zipkin.brave</groupId> - <artifactId>brave-bom</artifactId> - <version>${brave.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-dependencies</artifactId> - <version>${spring-boot-version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-bom</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> - - <!-- spring-boot --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> - - <!-- camel --> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-observation-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-jetty-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-http-starter</artifactId> - </dependency> - - - <!-- Micrometer Observation setup --> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-core</artifactId> - </dependency> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-tracing-bridge-brave</artifactId> - </dependency> - <!-- Reporter --> + <!-- Local reporter --> <dependency> <groupId>org.apache.camel.springboot.example</groupId> <artifactId>camel-example-spring-boot-observation-loggingtracer</artifactId> <version>${project.version}</version> </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>zipkin</id> - <dependencies> - <dependency> - <groupId>io.zipkin.reporter2</groupId> - <artifactId>zipkin-reporter-brave</artifactId> - </dependency> - <dependency> - <groupId>io.zipkin.reporter2</groupId> - <artifactId>zipkin-sender-urlconnection</artifactId> - </dependency> - </dependencies> - </profile> - <profile> - <id>prometheus</id> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-registry-prometheus</artifactId> - </dependency> - </dependencies> - </profile> - </profiles> - </project> diff --git a/observation/client/src/main/java/sample/camel/ClientRoute.java b/observation/client/src/main/java/sample/camel/ClientRoute.java index 4cad622..0e2b450 100644 --- a/observation/client/src/main/java/sample/camel/ClientRoute.java +++ b/observation/client/src/main/java/sample/camel/ClientRoute.java @@ -26,7 +26,7 @@ public class ClientRoute extends RouteBuilder { @Override public void configure() { // you can configure the route rule with Java DSL here - from("timer:trigger?exchangePattern=InOut&period=30000").streamCaching() + from("timer:trigger?exchangePattern=InOut&period=30000").streamCache("true") .bean("counterBean") .log("Client request: ${body}") .to("http://localhost:6060/service1") diff --git a/observation/client/src/main/resources/application.properties b/observation/client/src/main/resources/application.properties index f48d519..d68b6c4 100644 --- a/observation/client/src/main/resources/application.properties +++ b/observation/client/src/main/resources/application.properties @@ -22,5 +22,5 @@ camel.springboot.main-run-controller=true spring.application.name=${camel.main.name} management.tracing.sampling.probability=1.0 management.endpoints.web.exposure.include=health,metrics,prometheus -server.port=5432 +management.server.port=5432 logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}] diff --git a/observation/client/src/main/resources/log4j2.properties b/observation/client/src/main/resources/log4j2.properties deleted file mode 100644 index f25f872..0000000 --- a/observation/client/src/main/resources/log4j2.properties +++ /dev/null @@ -1,25 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -appender.stdout.type = Console -appender.stdout.name = stdout -appender.stdout.layout.type = PatternLayout -appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -logger.opentracing.name = org.apache.camel.opentracing -logger.opentracing.level = INFO -rootLogger.level = INFO -rootLogger.appenderRef.stdout.ref = stdout diff --git a/observation/client/src/main/resources/logback.xml b/observation/client/src/main/resources/logback.xml new file mode 100644 index 0000000..059315e --- /dev/null +++ b/observation/client/src/main/resources/logback.xml @@ -0,0 +1,33 @@ +<?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. + +--> +<!DOCTYPE xml> +<configuration> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern> + </encoder> + </appender> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration> \ No newline at end of file diff --git a/observation/containers/docker-compose.yml b/observation/containers/docker-compose.yml index e9ce8c6..fa5a17e 100644 --- a/observation/containers/docker-compose.yml +++ b/observation/containers/docker-compose.yml @@ -1,13 +1,15 @@ -version: "3" services: zipkin: container_name: camel_observation_zipkin - image: openzipkin/zipkin + image: mirror.gcr.io/openzipkin/zipkin + environment: + - STORAGE_TYPE=mem extra_hosts: ['host.docker.internal:host-gateway'] + # command: --logging.level.zipkin2=DEBUG --logging.level.io.mirometer=DEBUG ports: - 9411:9411 prometheus: - image: prom/prometheus + image: mirror.gcr.io/prom/prometheus container_name: camel_observation_prometheus extra_hosts: ['host.docker.internal:host-gateway'] command: @@ -18,7 +20,7 @@ services: ports: - 9090:9090 grafana: - image: grafana/grafana + image: mirror.gcr.io/grafana/grafana container_name: camel_observation_grafana extra_hosts: ['host.docker.internal:host-gateway'] environment: diff --git a/observation/loggingtracer/pom.xml b/observation/loggingtracer/pom.xml index 70a309d..aa70f4e 100644 --- a/observation/loggingtracer/pom.xml +++ b/observation/loggingtracer/pom.xml @@ -21,34 +21,17 @@ <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-observation</artifactId> - <version>4.12.0-SNAPSHOT</version> - </parent> - + <groupId>org.apache.camel.springboot.example</groupId> <artifactId>camel-example-spring-boot-observation-loggingtracer</artifactId> + <version>4.12.0-SNAPSHOT</version> <name>Camel SB Examples :: Observation :: LoggingTracer</name> <description>An example Observation Tracer</description> <properties> - <brave.version>5.15.0</brave.version> - <micrometer.version>1.10.4</micrometer.version> + <brave.version>6.0.3</brave.version> + <micrometer-tracing.version>1.5.0</micrometer-tracing.version> </properties> - <!-- import Camel BOM --> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-bom</artifactId> - <version>${camel-version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> <!-- tracer --> @@ -62,7 +45,7 @@ <dependency> <groupId>io.micrometer</groupId> <artifactId>micrometer-core</artifactId> - <version>${micrometer.version}</version> + <version>${micrometer-tracing.version}</version> </dependency> </dependencies> diff --git a/observation/pom.xml b/observation/pom.xml index 331b0e7..95a6e3f 100644 --- a/observation/pom.xml +++ b/observation/pom.xml @@ -36,8 +36,105 @@ <properties> <category>Management and Monitoring</category> <title>Micrometer Observation</title> + <micrometer-tracing.version>1.5.0</micrometer-tracing.version> </properties> + <!-- import Spring-Boot and Camel BOM --> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-tracing-bom</artifactId> + <version>${micrometer-tracing.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-spring-boot-bom</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring-boot-version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <!-- spring-boot --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + + <!-- camel --> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-observation-starter</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-http-starter</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-platform-http-starter</artifactId> + </dependency> + + <!-- Micrometer Observation setup --> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-tracing</artifactId> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-tracing-bridge-brave</artifactId> + </dependency> + <dependency> + <groupId>io.zipkin.reporter2</groupId> + <artifactId>zipkin-reporter-brave</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-registry-prometheus</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring-boot-version}</version> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + <modules> <module>loggingtracer</module> <module>client</module> diff --git a/observation/service1/pom.xml b/observation/service1/pom.xml index c6ed992..333c6e5 100644 --- a/observation/service1/pom.xml +++ b/observation/service1/pom.xml @@ -32,123 +32,13 @@ <description>An example showing how to trace incoming and outgoing messages from Camel with Micrometer Observation </description> - <properties> - <brave.version>5.15.0</brave.version> - </properties> - - <!-- import Spring-Boot and Camel BOM --> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>io.zipkin.brave</groupId> - <artifactId>brave-bom</artifactId> - <version>${brave.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-bom</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-dependencies</artifactId> - <version>${spring-boot-version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> - - <!-- spring-boot --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> - - <!-- camel --> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-observation-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-jetty-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-http-starter</artifactId> - </dependency> - - - <!-- Micrometer Observation setup --> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-core</artifactId> - </dependency> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-tracing-bridge-brave</artifactId> - </dependency> - <!-- Reporter --> + <!-- Local reporter --> <dependency> <groupId>org.apache.camel.springboot.example</groupId> <artifactId>camel-example-spring-boot-observation-loggingtracer</artifactId> <version>${project.version}</version> </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>zipkin</id> - <dependencies> - <dependency> - <groupId>io.zipkin.reporter2</groupId> - <artifactId>zipkin-reporter-brave</artifactId> - </dependency> - <dependency> - <groupId>io.zipkin.reporter2</groupId> - <artifactId>zipkin-sender-urlconnection</artifactId> - </dependency> - </dependencies> - </profile> - <profile> - <id>prometheus</id> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-registry-prometheus</artifactId> - </dependency> - </dependencies> - </profile> - </profiles> - </project> diff --git a/observation/service1/src/main/java/sample/camel/Service1Route.java b/observation/service1/src/main/java/sample/camel/Service1Route.java index 2a42fc2..34ce04c 100644 --- a/observation/service1/src/main/java/sample/camel/Service1Route.java +++ b/observation/service1/src/main/java/sample/camel/Service1Route.java @@ -24,7 +24,7 @@ public class Service1Route extends RouteBuilder { @Override public void configure() throws Exception { - from("jetty:http://0.0.0.0:{{service1.port}}/service1").routeId("service1").streamCaching() + from("platform-http:/service1").routeId("service1").streamCache("true") .removeHeaders("CamelHttp*") .log("Service1 request: ${body}") .delay(simple("${random(1000,2000)}")) diff --git a/observation/service1/src/main/resources/application.properties b/observation/service1/src/main/resources/application.properties index 6a39908..4b55ba3 100644 --- a/observation/service1/src/main/resources/application.properties +++ b/observation/service1/src/main/resources/application.properties @@ -22,10 +22,10 @@ camel.springboot.main-run-controller=true spring.application.name=${camel.main.name} management.tracing.sampling.probability=1.0 management.endpoints.web.exposure.include=health,metrics,prometheus -server.port=6543 +server.port=6060 +management.server.port=6543 logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}] # the port number the service will use for accepting incoming HTTP requests -service1.port=6060 +service1.port=${server.port} service2.port=7070 - diff --git a/observation/service1/src/main/resources/logback.xml b/observation/service1/src/main/resources/logback.xml new file mode 100644 index 0000000..059315e --- /dev/null +++ b/observation/service1/src/main/resources/logback.xml @@ -0,0 +1,33 @@ +<?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. + +--> +<!DOCTYPE xml> +<configuration> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern> + </encoder> + </appender> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration> \ No newline at end of file diff --git a/observation/service2/pom.xml b/observation/service2/pom.xml index f5c44bb..cd018ff 100644 --- a/observation/service2/pom.xml +++ b/observation/service2/pom.xml @@ -32,133 +32,13 @@ <description>An example showing how to trace incoming and outgoing messages from Camel with Micrometer Observation </description> - <properties> - <brave.version>5.15.0</brave.version> - </properties> - - <!-- import Spring-Boot and Camel BOM --> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>io.zipkin.brave</groupId> - <artifactId>brave-bom</artifactId> - <version>${brave.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-bom</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-dependencies</artifactId> - <version>${spring-boot-version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> - - <!-- spring-boot --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> - - <!-- camel --> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-observation-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-jetty-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-http-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-undertow-starter</artifactId> - </dependency> - - <!-- Micrometer Observation setup --> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-core</artifactId> - </dependency> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-tracing-bridge-brave</artifactId> - </dependency> - <!-- Reporter --> + <!-- Local reporter --> <dependency> <groupId>org.apache.camel.springboot.example</groupId> <artifactId>camel-example-spring-boot-observation-loggingtracer</artifactId> <version>${project.version}</version> </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>zipkin</id> - <dependencies> - <dependency> - <groupId>io.zipkin.reporter2</groupId> - <artifactId>zipkin-reporter-brave</artifactId> - </dependency> - <dependency> - <groupId>io.zipkin.reporter2</groupId> - <artifactId>zipkin-sender-urlconnection</artifactId> - </dependency> - </dependencies> - </profile> - <profile> - <id>prometheus</id> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>io.micrometer</groupId> - <artifactId>micrometer-registry-prometheus</artifactId> - </dependency> - </dependencies> - </profile> - </profiles> - </project> diff --git a/observation/service2/src/main/java/sample/camel/Service2Route.java b/observation/service2/src/main/java/sample/camel/Service2Route.java index a632c57..5b93fd0 100644 --- a/observation/service2/src/main/java/sample/camel/Service2Route.java +++ b/observation/service2/src/main/java/sample/camel/Service2Route.java @@ -25,7 +25,7 @@ public class Service2Route extends RouteBuilder { @Override public void configure() throws Exception { - from("undertow:http://0.0.0.0:7070/service2").routeId("service2").streamCaching() + from("platform-http:/service2").routeId("service2").streamCache("true") .log(" Service2 request: ${body}") .delay(simple("${random(1000,2000)}")) .transform(simple("Service2-${body}")) diff --git a/observation/service2/src/main/resources/application.properties b/observation/service2/src/main/resources/application.properties index 924cd7c..43c133e 100644 --- a/observation/service2/src/main/resources/application.properties +++ b/observation/service2/src/main/resources/application.properties @@ -22,6 +22,6 @@ camel.springboot.main-run-controller=true spring.application.name=${camel.main.name} management.tracing.sampling.probability=1.0 management.endpoints.web.exposure.include=health,metrics,prometheus -server.port=7654 +server.port=7070 +management.server.port=7654 logging.pattern.level=%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}] - diff --git a/observation/service2/src/main/resources/log4j2.properties b/observation/service2/src/main/resources/log4j2.properties deleted file mode 100644 index f25f872..0000000 --- a/observation/service2/src/main/resources/log4j2.properties +++ /dev/null @@ -1,25 +0,0 @@ -## --------------------------------------------------------------------------- -## 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. -## --------------------------------------------------------------------------- - -appender.stdout.type = Console -appender.stdout.name = stdout -appender.stdout.layout.type = PatternLayout -appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -logger.opentracing.name = org.apache.camel.opentracing -logger.opentracing.level = INFO -rootLogger.level = INFO -rootLogger.appenderRef.stdout.ref = stdout diff --git a/observation/service2/src/main/resources/logback.xml b/observation/service2/src/main/resources/logback.xml new file mode 100644 index 0000000..059315e --- /dev/null +++ b/observation/service2/src/main/resources/logback.xml @@ -0,0 +1,33 @@ +<?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. + +--> +<!DOCTYPE xml> +<configuration> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern> + </encoder> + </appender> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + +</configuration> \ No newline at end of file diff --git a/platform-http/README.adoc b/platform-http/README.adoc index 2d5b300..a449f13 100644 --- a/platform-http/README.adoc +++ b/platform-http/README.adoc @@ -4,7 +4,7 @@ This example illustrates how to use https://projects.spring.io/spring-boot/[Spring Boot] with http://camel.apache.org[Camel]. It provides a simple REST service that is created with http://camel.apache.org/rest-dsl.html[Camel REST DSL] and https://camel.apache.org/components/3.18.x/platform-http-component.html[platform-http]. -The project uses the `camel-spring-boot-starter` dependency, a Spring Boot starter dependency for Camel that simplifies the Maven configuration. +The project uses the `camel-spring-boot-starter` dependency, a Spring Boot starter dependency for Camel that simplifies the Maven configuration. The project also uses `camel-servlet-starter` component as the implementation for platform-http-engine. @@ -12,15 +12,21 @@ The project also uses `camel-servlet-starter` component as the implementation fo You can build this example using: - $ mvn package +[source,text] +---- +mvn package +---- === Run You can run this example using: - $ mvn spring-boot:run +[source,text] +---- +mvn spring-boot:run +---- -You should see the following output when the application is launched: +You should see the following output when the application is launched (timestamp removed for simplicity): [source,text] ---- @@ -31,24 +37,28 @@ You should see the following output when the application is launched: \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ - ... -2022-09-05 12:00:31.101 INFO 16692 --- [ main] o.a.c.c.s.CamelHttpTransportServlet : Initialized CamelHttpTransportServlet[name=CamelServlet, contextPath=] -2022-09-05 12:00:31.113 INFO 16692 --- [ main] io.undertow : starting server: Undertow - 2.2.19.Final -2022-09-05 12:00:31.128 INFO 16692 --- [ main] org.xnio : XNIO version 3.8.7.Final -2022-09-05 12:00:31.144 INFO 16692 --- [ main] org.xnio.nio : XNIO NIO Implementation Version 3.8.7.Final -2022-09-05 12:00:31.354 INFO 16692 --- [ main] org.jboss.threads : JBoss Threads version 3.1.0.Final -2022-09-05 12:00:31.453 INFO 16692 --- [ main] o.s.b.w.e.undertow.UndertowWebServer : Undertow started on port(s) 8080 (http) -2022-09-05 12:00:31.955 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.0.0-SNAPSHOT (MyCamel) is starting -2022-09-05 12:00:31.989 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Routes startup (started:7) -2022-09-05 12:00:31.989 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route1 (direct://test) -2022-09-05 12:00:31.989 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route2 (rest://get:/todos) -2022-09-05 12:00:31.989 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route3 (rest://get:/todos:/%7Bid%7D) -2022-09-05 12:00:31.990 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route4 (rest://patch:/todos:/%7Bid%7D) -2022-09-05 12:00:31.990 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route5 (rest://post:/todos) -2022-09-05 12:00:31.990 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route6 (rest://delete:/todos) -2022-09-05 12:00:31.991 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started route7 (rest://delete:/todos:/%7Bid%7D) -2022-09-05 12:00:31.992 INFO 16692 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.0.0-SNAPSHOT (MyCamel) started in 552ms (build:95ms init:421ms start:36ms) -2022-09-05 12:00:32.005 INFO 16692 --- [ main] o.a.c.example.springboot.Application : Started Application in 13.737 seconds (JVM running for 14.657) + + :: Spring Boot :: (v3.4.5) + +o.a.c.example.springboot.Application : Starting Application using Java 17.0.15 with PID 3707237 +o.a.c.example.springboot.Application : No active profile set, falling back to 1 default profile: "default" +o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http) +o.apache.catalina.core.StandardService : Starting service [Tomcat] +o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.40] +o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 451 ms +o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/' +o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.12.0-SNAPSHOT (MyCamel) is starting +o.a.c.impl.engine.AbstractCamelContext : Routes startup (total:6 rest-dsl:6) +o.a.c.impl.engine.AbstractCamelContext : Started route1 (rest://get:/todos) +o.a.c.impl.engine.AbstractCamelContext : Started route2 (rest://get:/todos:/%7Bid%7D) +o.a.c.impl.engine.AbstractCamelContext : Started route3 (rest://patch:/todos:/%7Bid%7D) +o.a.c.impl.engine.AbstractCamelContext : Started route4 (rest://post:/todos) +o.a.c.impl.engine.AbstractCamelContext : Started route5 (rest://delete:/todos) +o.a.c.impl.engine.AbstractCamelContext : Started route6 (rest://delete:/todos:/%7Bid%7D) +o.a.c.impl.engine.AbstractCamelContext : Apache Camel 4.12.0-SNAPSHOT (MyCamel) started in 8ms (build:0ms init:0ms start:8ms boot:428ms) +o.a.c.example.springboot.Application : Started Application in 1.155 seconds (process running for 1.283) + ---- After the Spring Boot application is started, you can execute the following HTTP requests: @@ -57,7 +67,7 @@ Create a TODO [source,text] ---- -$ curl -d '{"title":"Todo title", "completed":"false", "order": 1, "url":""}' -H "Content-Type: application/json" -X POST http://localhost:8080/todos +curl -d '{"title":"Todo title", "completed":"false", "order": 1, "url":""}' -H "Content-Type: application/json" -X POST http://localhost:8080/todos ---- The command will produce the following output: @@ -71,7 +81,7 @@ Retrieve all TODOs [source,text] ---- -$ curl http://localhost:8080/todos +curl http://localhost:8080/todos ---- The command will produce the following output: @@ -85,7 +95,7 @@ Update one TODO [source,text] ---- -$ curl -d '{"title":"Todo title", "completed":"true", "order": 1, "url":""}' -H "Content-Type: application/json" -X PATCH http://localhost:8080/todos/1 +curl -d '{"title":"Todo title", "completed":"true", "order": 1, "url":""}' -H "Content-Type: application/json" -X PATCH http://localhost:8080/todos/1 ---- The command will produce the following output: @@ -99,7 +109,7 @@ Delete completed TODOs [source,text] ---- -$ curl -X "DELETE" http://localhost:8080/todos +curl -X "DELETE" http://localhost:8080/todos ---- The command will produce the following output: diff --git a/resilience4j/README.adoc b/resilience4j/README.adoc index b898e93..aaf1985 100644 --- a/resilience4j/README.adoc +++ b/resilience4j/README.adoc @@ -27,7 +27,7 @@ You will need to compile this example first: [source,sh] ---- -$ mvn compile +mvn compile ---- === Run the example @@ -37,16 +37,14 @@ the client. [source,sh] ---- -$ cd service1 -$ mvn compile spring-boot:run +mvn -f service1 spring-boot:run ---- When service1 is ready then start service2 [source,sh] ---- -$ cd service2 -$ mvn compile camel:run +mvn -f service2 camel:run ---- And then start the client that calls service1 every second. @@ -58,16 +56,14 @@ To use Spring Boot [source,sh] ---- -$ cd client -$ mvn compile spring-boot:run +mvn -f client compile spring-boot:run ---- Or to use Camel Main [source,sh] ---- -$ cd client2 -$ mvn compile camel:run +mvn -f client2 compile camel:run ---- You can then stop service1 and see that the client should fallback to diff --git a/resilience4j/client/src/main/java/sample/camel/ClientRoute.java b/resilience4j/client/src/main/java/sample/camel/ClientRoute.java index 1edd6f6..a848843 100644 --- a/resilience4j/client/src/main/java/sample/camel/ClientRoute.java +++ b/resilience4j/client/src/main/java/sample/camel/ClientRoute.java @@ -25,7 +25,7 @@ public class ClientRoute extends RouteBuilder { @Override public void configure() { // you can configure the route rule with Java DSL here - from("timer:trigger?period=500").streamCaching() + from("timer:trigger?period=500").streamCache("true") .bean("counterBean") .log(" Client request: ${body}") .circuitBreaker() diff --git a/resilience4j/client2/pom.xml b/resilience4j/client2/pom.xml index 7ebbc09..e186357 100644 --- a/resilience4j/client2/pom.xml +++ b/resilience4j/client2/pom.xml @@ -67,7 +67,16 @@ <groupId>org.apache.camel</groupId> <artifactId>camel-timer</artifactId> </dependency> - + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4j2-version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>${log4j2-version}</version> + </dependency> </dependencies> <build> diff --git a/resilience4j/client2/src/main/java/sample/camel/Client2Route.java b/resilience4j/client2/src/main/java/sample/camel/Client2Route.java index 8e7065b..9750a0e 100644 --- a/resilience4j/client2/src/main/java/sample/camel/Client2Route.java +++ b/resilience4j/client2/src/main/java/sample/camel/Client2Route.java @@ -23,7 +23,7 @@ public class Client2Route extends RouteBuilder { @Override public void configure() { // you can configure the route rule with Java DSL here - from("timer:trigger?period=500").streamCaching() + from("timer:trigger?period=500").streamCache("true") .bean("counterBean") .log(" Client request: ${body}") .circuitBreaker() diff --git a/resilience4j/pom.xml b/resilience4j/pom.xml index aae19d7..de32fb0 100644 --- a/resilience4j/pom.xml +++ b/resilience4j/pom.xml @@ -34,6 +34,7 @@ <properties> <category>EIP</category> + <log4j2-version>2.24.3</log4j2-version> </properties> <modules> diff --git a/resilience4j/service1/pom.xml b/resilience4j/service1/pom.xml index e3532b9..6aeb6ed 100644 --- a/resilience4j/service1/pom.xml +++ b/resilience4j/service1/pom.xml @@ -31,9 +31,6 @@ <name>Camel SB Examples :: Resilience4j :: Service 1</name> <description>An example showing how to use Resilience4j EIP as circuit breaker in Camel routes</description> - <properties> - </properties> - <!-- import Spring-Boot and Camel BOM --> <dependencyManagement> <dependencies> @@ -73,7 +70,7 @@ </dependency> <dependency> <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-jetty-starter</artifactId> + <artifactId>camel-platform-http-starter</artifactId> </dependency> <dependency> <groupId>org.apache.camel.springboot</groupId> diff --git a/resilience4j/service1/src/main/java/sample/camel/Service1Route.java b/resilience4j/service1/src/main/java/sample/camel/Service1Route.java index 4d82ea0..d906cce 100644 --- a/resilience4j/service1/src/main/java/sample/camel/Service1Route.java +++ b/resilience4j/service1/src/main/java/sample/camel/Service1Route.java @@ -24,7 +24,7 @@ public class Service1Route extends RouteBuilder { @Override public void configure() throws Exception { - from("jetty:http://0.0.0.0:{{service1.port}}/service1").routeId("service1").streamCaching() + from("platform-http:/service1").routeId("service1").streamCache("true") .log("Service1 request: ${body}") .transform(simple("Service1-${body}")) .log("Service1 response: ${body}"); diff --git a/resilience4j/service1/src/main/resources/application.properties b/resilience4j/service1/src/main/resources/application.properties index 6c90b59..bf7952f 100644 --- a/resilience4j/service1/src/main/resources/application.properties +++ b/resilience4j/service1/src/main/resources/application.properties @@ -18,8 +18,8 @@ # the name of Camel camel.main.name=Service1 camel.springboot.main-run-controller=true +server.port=9090 # the port number the service will use for accepting incoming HTTP requests -service1.port=9090 +service1.port=${server.port} service2.port=7070 - diff --git a/resilience4j/service2/pom.xml b/resilience4j/service2/pom.xml index 18555a2..fc3aa16 100644 --- a/resilience4j/service2/pom.xml +++ b/resilience4j/service2/pom.xml @@ -57,7 +57,17 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> - <artifactId>camel-undertow</artifactId> + <artifactId>camel-platform-http-main</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>${log4j2-version}</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>${log4j2-version}</version> </dependency> </dependencies> diff --git a/resilience4j/service2/src/main/java/sample/camel/Service2Route.java b/resilience4j/service2/src/main/java/sample/camel/Service2Route.java index 8e3ff80..2513cf3 100644 --- a/resilience4j/service2/src/main/java/sample/camel/Service2Route.java +++ b/resilience4j/service2/src/main/java/sample/camel/Service2Route.java @@ -22,7 +22,7 @@ public class Service2Route extends RouteBuilder { @Override public void configure() throws Exception { - from("undertow:http://0.0.0.0:7070/service2").routeId("service2").streamCaching() + from("platform-http:/service2").routeId("service2").streamCache("true") .log(" Service2 request: ${body}") .transform(simple("Service2-${body}")) .log("Service2 response: ${body}"); diff --git a/resilience4j/service1/src/main/resources/application.properties b/resilience4j/service2/src/main/resources/application.properties similarity index 90% copy from resilience4j/service1/src/main/resources/application.properties copy to resilience4j/service2/src/main/resources/application.properties index 6c90b59..cd972bd 100644 --- a/resilience4j/service1/src/main/resources/application.properties +++ b/resilience4j/service2/src/main/resources/application.properties @@ -16,10 +16,8 @@ ## --------------------------------------------------------------------------- # the name of Camel -camel.main.name=Service1 -camel.springboot.main-run-controller=true +camel.main.name=Service2 +camel.server.enabled=true # the port number the service will use for accepting incoming HTTP requests -service1.port=9090 -service2.port=7070 - +camel.server.port=7070 diff --git a/resilience4j/service2/src/main/resources/log4j2.properties b/resilience4j/service2/src/main/resources/log4j2.properties index 6f76518..f02e7ae 100644 --- a/resilience4j/service2/src/main/resources/log4j2.properties +++ b/resilience4j/service2/src/main/resources/log4j2.properties @@ -19,7 +19,5 @@ appender.stdout.type = Console appender.stdout.name = stdout appender.stdout.layout.type = PatternLayout appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n -logger.zipkin.name = org.apache.camel.zipkin -logger.zipkin.level = DEBUG rootLogger.level = INFO rootLogger.appenderRef.stdout.ref = stdout diff --git a/saga/local-resources/compose.yaml b/saga/local-resources/compose.yaml index d20dfb5..591f161 100644 --- a/saga/local-resources/compose.yaml +++ b/saga/local-resources/compose.yaml @@ -3,7 +3,7 @@ services: image: "quay.io/jbosstm/lra-coordinator:latest" network_mode: "host" amq-broker: - image: "registry.redhat.io/amq7/amq-broker-rhel8:7.11.0" + image: "registry.redhat.io/amq7/amq-broker-rhel8:7.12" environment: - AMQ_USER=admin - AMQ_PASSWORD=admin diff --git a/saga/ocp-resources/amq-broker-ephemeral.yaml b/saga/ocp-resources/amq-broker-ephemeral.yaml index 74330b0..2fb09ec 100644 --- a/saga/ocp-resources/amq-broker-ephemeral.yaml +++ b/saga/ocp-resources/amq-broker-ephemeral.yaml @@ -35,7 +35,7 @@ items: tags: - from: kind: DockerImage - name: registry.redhat.io/amq7/amq-broker-rhel8:7.11.0 + name: registry.redhat.io/amq7/amq-broker-rhel8:7.12 generation: 0 importPolicy: {} name: "latest" diff --git a/saga/pom.xml b/saga/pom.xml index 90f1f63..5b5e62e 100644 --- a/saga/pom.xml +++ b/saga/pom.xml @@ -34,7 +34,7 @@ <properties> <category>EIP</category> - + <jakarta-servlet-api-version>6.1.0</jakarta-servlet-api-version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> </properties> @@ -47,7 +47,6 @@ </modules> <dependencyManagement> - <dependencies> <!-- Camel BOM --> <dependency> @@ -68,45 +67,39 @@ </dependencies> </dependencyManagement> - <dependencies> - + <!-- spring-boot --> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - </exclusion> - </exclusions> </dependency> <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-undertow-starter</artifactId> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> </dependency> - + <!-- Camel --> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-servlet-starter</artifactId> </dependency> - + <!-- required for camel-servlet since it's set as provided in the camel component --> <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> + <groupId>jakarta.servlet</groupId> + <artifactId>jakarta.servlet-api</artifactId> + <version>${jakarta-servlet-api-version}</version> </dependency> - <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-jms-starter</artifactId> </dependency> - <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-lra-starter</artifactId> </dependency> - - <!-- Camel --> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-starter</artifactId> @@ -134,4 +127,62 @@ <scope>test</scope> </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>${spring-boot-version}</version> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>openshift</id> + <activation> + <property> + <name>openshift</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>openshift-maven-plugin</artifactId> + <groupId>org.eclipse.jkube</groupId> + <executions> + <execution> + <goals> + <goal>resource</goal> + <goal>build</goal> + <goal>deploy</goal> + </goals> + </execution> + </executions> + <configuration> + <resources> + <labels> + <all> + <property> + <name>csbexample</name> + <value>saga</value> + </property> + </all> + </labels> + </resources> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/saga/run-local.sh b/saga/run-local.sh index f019607..5ffb270 100755 --- a/saga/run-local.sh +++ b/saga/run-local.sh @@ -7,17 +7,13 @@ echo compiling project mvn clean package echo running payment service -java -Dserver.port=8081 -jar saga-payment-service/target/*.jar > payment.log 2>&1 & -echo "$!" > payment.pid +mvn -f saga-payment-service/ spring-boot:run echo running flight service -java -Dserver.port=8082 -jar saga-flight-service/target/*.jar > flight.log 2>&1 & -echo "$!" > flight.pid +mvn -f saga-flight-service/ spring-boot:run echo running train service -java -Dserver.port=8083 -jar saga-train-service/target/*.jar > train.log 2>&1 & -echo "$!" > train.pid +mvn -f saga-train-service/ spring-boot:run echo running saga application -java -Dserver.port=8084 -jar saga-app/target/*.jar > app.log 2>&1 & -echo "$!" > app.pid +mvn -f saga-app/ spring-boot:run diff --git a/saga/saga-app/pom.xml b/saga/saga-app/pom.xml index 68114c2..7c5be74 100644 --- a/saga/saga-app/pom.xml +++ b/saga/saga-app/pom.xml @@ -31,68 +31,4 @@ <name>Camel SB Examples :: Saga :: App</name> <description>Main application starting SAGA</description> - <properties> - <category>EIP</category> - - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>openshift</id> - <activation> - <property> - <name>openshift</name> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>openshift-maven-plugin</artifactId> - <groupId>org.eclipse.jkube</groupId> - <executions> - <execution> - <goals> - <goal>resource</goal> - <goal>build</goal> - <goal>deploy</goal> - </goals> - </execution> - </executions> - <configuration> - <resources> - <labels> - <all> - <property> - <name>csbexample</name> - <value>saga</value> - </property> - </all> - </labels> - </resources> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> - </project> diff --git a/saga/saga-app/src/main/resources/application.yml b/saga/saga-app/src/main/resources/application.yml index bd33884..95d1a2c 100644 --- a/saga/saga-app/src/main/resources/application.yml +++ b/saga/saga-app/src/main/resources/application.yml @@ -22,6 +22,8 @@ spring: user: admin password: admin pool.enabled: true +server: + port: 8084 camel: servlet: mapping: @@ -50,4 +52,3 @@ logging: org.apache.camel.processor.errorhandler.DefaultErrorHandler: OFF org.apache.camel.component.jms.EndpointMessageListener: OFF org.apache.camel.component.jms.reply.QueueReplyManager: OFF - diff --git a/saga/saga-flight-service/pom.xml b/saga/saga-flight-service/pom.xml index 93f0280..ab3f53b 100644 --- a/saga/saga-flight-service/pom.xml +++ b/saga/saga-flight-service/pom.xml @@ -31,68 +31,4 @@ <name>Camel SB Examples :: Saga :: Flight Service</name> <description>Flight Service</description> - <properties> - <category>EIP</category> - - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>openshift</id> - <activation> - <property> - <name>openshift</name> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>openshift-maven-plugin</artifactId> - <groupId>org.eclipse.jkube</groupId> - <executions> - <execution> - <goals> - <goal>resource</goal> - <goal>build</goal> - <goal>deploy</goal> - </goals> - </execution> - </executions> - <configuration> - <resources> - <labels> - <all> - <property> - <name>csbexample</name> - <value>saga</value> - </property> - </all> - </labels> - </resources> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> - </project> diff --git a/saga/saga-flight-service/src/main/resources/application.yml b/saga/saga-flight-service/src/main/resources/application.yml index e2ab4ec..614d46d 100644 --- a/saga/saga-flight-service/src/main/resources/application.yml +++ b/saga/saga-flight-service/src/main/resources/application.yml @@ -22,6 +22,8 @@ spring: user: admin password: admin pool.enabled: true +server: + port: 8082 camel: servlet: mapping: @@ -50,4 +52,3 @@ logging: org.apache.camel.processor.errorhandler.DefaultErrorHandler: OFF org.apache.camel.component.jms.EndpointMessageListener: OFF org.apache.camel.component.jms.reply.QueueReplyManager: OFF - diff --git a/saga/saga-payment-service/pom.xml b/saga/saga-payment-service/pom.xml index 472f364..55c8054 100644 --- a/saga/saga-payment-service/pom.xml +++ b/saga/saga-payment-service/pom.xml @@ -31,68 +31,4 @@ <name>Camel SB Examples :: Saga :: Payment Service</name> <description>Payment Service</description> - <properties> - <category>EIP</category> - - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>openshift</id> - <activation> - <property> - <name>openshift</name> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>openshift-maven-plugin</artifactId> - <groupId>org.eclipse.jkube</groupId> - <executions> - <execution> - <goals> - <goal>resource</goal> - <goal>build</goal> - <goal>deploy</goal> - </goals> - </execution> - </executions> - <configuration> - <resources> - <labels> - <all> - <property> - <name>csbexample</name> - <value>saga</value> - </property> - </all> - </labels> - </resources> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> - </project> diff --git a/saga/saga-payment-service/src/main/resources/application.yml b/saga/saga-payment-service/src/main/resources/application.yml index 6730035..56ab3f6 100644 --- a/saga/saga-payment-service/src/main/resources/application.yml +++ b/saga/saga-payment-service/src/main/resources/application.yml @@ -22,6 +22,8 @@ spring: user: admin password: admin pool.enabled: true +server: + port: 8081 camel: servlet: mapping: @@ -49,4 +51,3 @@ logging: org.apache.camel.processor.errorhandler.DefaultErrorHandler: OFF org.apache.camel.component.jms.EndpointMessageListener: OFF org.apache.camel.component.jms.reply.QueueReplyManager: OFF - diff --git a/saga/saga-train-service/pom.xml b/saga/saga-train-service/pom.xml index 252e3f5..908488f 100644 --- a/saga/saga-train-service/pom.xml +++ b/saga/saga-train-service/pom.xml @@ -31,68 +31,4 @@ <name>Camel SB Examples :: Saga :: Train Service</name> <description>Train Service</description> - <properties> - <category>EIP</category> - - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>openshift</id> - <activation> - <property> - <name>openshift</name> - </property> - </activation> - <build> - <plugins> - <plugin> - <artifactId>openshift-maven-plugin</artifactId> - <groupId>org.eclipse.jkube</groupId> - <executions> - <execution> - <goals> - <goal>resource</goal> - <goal>build</goal> - <goal>deploy</goal> - </goals> - </execution> - </executions> - <configuration> - <resources> - <labels> - <all> - <property> - <name>csbexample</name> - <value>saga</value> - </property> - </all> - </labels> - </resources> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> - </project> diff --git a/saga/saga-train-service/src/main/resources/application.yml b/saga/saga-train-service/src/main/resources/application.yml index 2e5081c..1a17b3a 100644 --- a/saga/saga-train-service/src/main/resources/application.yml +++ b/saga/saga-train-service/src/main/resources/application.yml @@ -22,6 +22,8 @@ spring: user: admin password: admin pool.enabled: true +server: + port: 8083 camel: servlet: mapping: @@ -50,4 +52,3 @@ logging: org.apache.camel.processor.errorhandler.DefaultErrorHandler: OFF org.apache.camel.component.jms.EndpointMessageListener: OFF org.apache.camel.component.jms.reply.QueueReplyManager: OFF - diff --git a/soap-cxf/pom.xml b/soap-cxf/pom.xml index 7f31d49..a36d5ed 100644 --- a/soap-cxf/pom.xml +++ b/soap-cxf/pom.xml @@ -65,27 +65,18 @@ </dependencyManagement> <dependencies> <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-starter</artifactId> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - </exclusion> - </exclusions> </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-undertow</artifactId> - </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> + <!-- camel --> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-bean-validator-starter</artifactId> @@ -94,25 +85,9 @@ <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-cxf-soap-starter</artifactId> </dependency> - - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-servlet-starter</artifactId> - </dependency> <dependency> <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-jackson-starter</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.cxf</groupId> - <artifactId>cxf-spring-boot-starter-jaxws</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - </exclusion> - </exclusions> + <artifactId>camel-platform-http-starter</artifactId> </dependency> <dependency> diff --git a/soap-cxf/src/main/java/sample/camel/UndertowConfiguration.java b/soap-cxf/src/main/java/sample/camel/UndertowConfiguration.java deleted file mode 100644 index 0da059e..0000000 --- a/soap-cxf/src/main/java/sample/camel/UndertowConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - */ -package sample.camel; - - - -import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer; -import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; -import org.springframework.boot.web.server.WebServerFactoryCustomizer; - -import org.springframework.stereotype.Component; - -import io.undertow.server.HandlerWrapper; -import io.undertow.server.HttpHandler; -import io.undertow.server.handlers.RequestLimitingHandler; -import io.undertow.servlet.api.DeploymentInfo; - -@Component -public class UndertowConfiguration implements WebServerFactoryCustomizer<UndertowServletWebServerFactory> { - @Override - public void customize(UndertowServletWebServerFactory factory) { - factory.addDeploymentInfoCustomizers(new UndertowDeploymentInfoCustomizer() { - @Override - public void customize(DeploymentInfo deploymentInfo) { - // Enable RequestLimitingHandler - // we actually can configure all applicable undertow handlers here - deploymentInfo.addOuterHandlerChainWrapper(new HandlerWrapper() { - @Override - public HttpHandler wrap(HttpHandler handler) { - - return new RequestLimitingHandler(1, 1, handler); - } - }); - } - }); - - - } -} diff --git a/soap-cxf/src/main/resources/application.properties b/soap-cxf/src/main/resources/application.properties index e2a8dbe..c242c92 100644 --- a/soap-cxf/src/main/resources/application.properties +++ b/soap-cxf/src/main/resources/application.properties @@ -23,3 +23,5 @@ camel.springboot.main-run-controller=true management.endpoint.metrics.enabled=true management.endpoints.web.exposure.include=* + +server.tomcat.accept-count=1 diff --git a/soap-cxf/src/test/java/sample/camel/PojoClientTest.java b/soap-cxf/src/test/java/sample/camel/PojoClientTest.java index b493564..6607718 100644 --- a/soap-cxf/src/test/java/sample/camel/PojoClientTest.java +++ b/soap-cxf/src/test/java/sample/camel/PojoClientTest.java @@ -68,6 +68,6 @@ public class PojoClientTest { Assertions.assertThat(cxfClient.getContact("Croway")).isNotNull(); - Assertions.assertThatThrownBy(() -> cxfClient.getContact("Non existent")).isInstanceOf(NoSuchContactException.class); + Assertions.assertThatThrownBy(() -> cxfClient.getContact("Non existent - this error is expected")).isInstanceOf(NoSuchContactException.class); } } diff --git a/soap-cxf/src/test/java/sample/camel/WsdlClientTest.java b/soap-cxf/src/test/java/sample/camel/WsdlClientTest.java index f234ca1..75887f9 100644 --- a/soap-cxf/src/test/java/sample/camel/WsdlClientTest.java +++ b/soap-cxf/src/test/java/sample/camel/WsdlClientTest.java @@ -67,43 +67,43 @@ public class WsdlClientTest { public void before() { cxfClient = createCustomerClient(); } - + @Test - public void testRequestLimiting() throws Exception { - CountDownLatch latch = new CountDownLatch(50); + public void testRequestLimiting() throws Exception { + CountDownLatch latch = new CountDownLatch(50); - ExecutorService executor = Executors.newFixedThreadPool(200); + ExecutorService executor = Executors.newFixedThreadPool(200); - for (int i = 0; i < 50; i++) { - executor.execute(new SendRequest(latch)); - } - latch.await(); + for (int i = 0; i < 50; i++) { + executor.execute(new SendRequest(latch)); } + latch.await(); + } - class SendRequest implements Runnable { + class SendRequest implements Runnable { - CountDownLatch latch; + CountDownLatch latch; - SendRequest(CountDownLatch latch) { - this.latch = latch; - } + SendRequest(CountDownLatch latch) { + this.latch = latch; + } - @Override - public void run() { - try { - List<Customer> customers = cxfClient.getCustomersByName("test"); - assertEquals(customers.get(0).getName(), "test"); - assertEquals(customers.get(0).getCustomerId(), 1); - - } catch (Exception ex) { - // some requests are expected to fail and receive 503 error - // cause Server side limit the concurrent request - assertTrue(ex.getCause().getMessage().contains("503: Service Unavailable")); - } finally { - latch.countDown(); - } + @Override + public void run() { + try { + List<Customer> customers = cxfClient.getCustomersByName("test"); + assertEquals(customers.get(0).getName(), "test"); + assertEquals(customers.get(0).getCustomerId(), 1); + + } catch (Exception ex) { + // some requests are expected to fail and receive errors + // cause Server side limit the concurrent request + assertTrue(ex.getCause().getMessage().contains("header parser received no bytes")); + } finally { + latch.countDown(); } } + } @Test public void testGetCustomer() throws Exception { diff --git a/spring-jdbc/pom.xml b/spring-jdbc/pom.xml index 5865349..4970960 100644 --- a/spring-jdbc/pom.xml +++ b/spring-jdbc/pom.xml @@ -58,23 +58,11 @@ </dependencies> </dependencyManagement> - <dependencies> - <!-- Spring Boot --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-undertow</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/spring-jdbc/readme.adoc b/spring-jdbc/readme.adoc index d778f89..f3e2734 100644 --- a/spring-jdbc/readme.adoc +++ b/spring-jdbc/readme.adoc @@ -5,7 +5,7 @@ This example shows how `transacted()` routes create a jdbc local transaction int === How to run Run the database container - podman run --rm --name db -e POSTGRES_PASSWORD=password -p 5432:5432 docker.io/library/postgres:latest + podman run --rm --name db -e POSTGRES_PASSWORD=password -p 5432:5432 mirror.gcr.io/library/postgres:latest You can run this example using @@ -19,7 +19,7 @@ To execute the routes: 2. insert data - curl -X POST http://localhost:8080/api/horses -H "name: Varenne" -H "age: 8" + curl -X POST http://localhost:8080/api/horses -H "name: Varenne" -H "age: 8" 3. verify the data has been persisted