This is an automated email from the ASF dual-hosted git repository. fmariani 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 9b984cd reactive-streams: need to fix sb component scan and rest example 9b984cd is described below commit 9b984cd8c04e59d94f21b9c8ea0c8f5336b54c7e Author: Salvatore Mongiardo <smong...@redhat.com> AuthorDate: Wed May 28 18:16:11 2025 +0200 reactive-streams: need to fix sb component scan and rest example --- reactive-streams/readme.adoc | 27 +++++++++++++++++++++- .../reactive/streams/ClientAPIWorkflowExample.java | 2 +- .../example/reactive/streams/RestExample.java | 4 ++-- .../streams/app/ReactiveStreamsSpringBootApp.java | 2 ++ 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/reactive-streams/readme.adoc b/reactive-streams/readme.adoc index b25103b..f9bce2c 100644 --- a/reactive-streams/readme.adoc +++ b/reactive-streams/readme.adoc @@ -2,6 +2,8 @@ This example shows some possible usages of the Camel reactive streams component. +=== Introduction + The following sample routes are started together in a spring-boot application (all routes use `reactor-core` as external reactive framework): - **examples.basic.camel-to-reactor**: shows how data generated by Camel route can be consumed by a reactive application. @@ -9,7 +11,7 @@ The following sample routes are started together in a spring-boot application (a - **examples.basic.reactor-to-camel**: shows how data generated by a reactive application can be consumed by a Camel route. - **examples.basic.reactor-to-camel-in-out**: shows how data generated by a reactive application can can be processed by Camel and return back to the library to complete the flow. - **examples.client-api.rest**: shows how a rest service can be defined using the reactive streams client API only. -- **examples.client-api.workflow**: shows how multiple Camel endpoints can be used into a reactive streams processing flow. +- **examples.client-api.workflow**: shows how multiple Camel endpoints can be used into a reactive streams processing flow. It reads from an "input" named directory, filtering files containing "camel" as text as criteria before sending to an external system - **examples.others.rest**: shows how `Publisher` classes can be used as parameters or return types in beans. All routes are enabled by default, but they can be switched off by changing the `src/main/resources/application.yml` file. @@ -21,6 +23,29 @@ You can run this example using mvn spring-boot:run +In some cases the camel reactor streams routes can be verified during execution of application, but we can also verify the functionality of reactor subscriptions through some defined Rest APIs. + +Rest API to retrieve informations about orders: + +http://localhost:8080/camel/orders/1 +http://localhost:8080/camel/orders/2 + +If we call: + +---- +curl http://localhost:8080/camel/orders/3 +---- + +We should receive a message "Not Found" as result of Flux Reactor coded behaviour + +Rest API for reactor managed calculator: + +---- +curl http://localhost:8080/camel/sum/23/31 +---- + +Let verify "54" as result + === Help and contributions If you hit any problem using Camel or have some feedback, then please diff --git a/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/ClientAPIWorkflowExample.java b/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/ClientAPIWorkflowExample.java index dce5545..4a61740 100644 --- a/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/ClientAPIWorkflowExample.java +++ b/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/ClientAPIWorkflowExample.java @@ -80,7 +80,7 @@ public class ClientAPIWorkflowExample { .log("Content marshalled to string: ${body}"); from("direct:send") - .log("Sending the file to an external system (simulation)"); + .log("Sending the file to an external system (simulation) with text: ${body}"); } diff --git a/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/RestExample.java b/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/RestExample.java index ebd72e6..d59d41c 100644 --- a/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/RestExample.java +++ b/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/RestExample.java @@ -70,8 +70,8 @@ public class RestExample { .to("direct:sum"); from("direct:sum") - .setHeader("num1").simple("${headerAs(num1,Long)}") - .setHeader("num2").simple("${headerAs(num2,Long)}") + .setHeader("num1").simple("${header.num1}",Long.class) + .setHeader("num2").simple("${header.num2}",Long.class) .bean("calculator", "sum") .process(new UnwrapStreamProcessor()) .setBody().simple("The result is: ${body}"); diff --git a/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/app/ReactiveStreamsSpringBootApp.java b/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/app/ReactiveStreamsSpringBootApp.java index d30830c..9268478 100644 --- a/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/app/ReactiveStreamsSpringBootApp.java +++ b/reactive-streams/src/main/java/org/apache/camel/example/reactive/streams/app/ReactiveStreamsSpringBootApp.java @@ -17,10 +17,12 @@ package org.apache.camel.example.reactive.streams.app; import org.springframework.boot.SpringApplication; +import org.springframework.context.annotation.ComponentScan; import org.springframework.boot.autoconfigure.SpringBootApplication; //CHECKSTYLE:OFF @SpringBootApplication +@ComponentScan(basePackages = "org.apache.camel.example.reactive.streams") public class ReactiveStreamsSpringBootApp { public static void main(String[] args) {