Remove complex non manintaned example
diff --git a/README.adoc b/README.adoc index a9b2748..98df5fa 100644 --- a/README.adoc +++ b/README.adoc
@@ -27,7 +27,7 @@ === Examples // examples: START -Number of Examples: 63 (0 deprecated) +Number of Examples: 62 (0 deprecated) [width="100%",cols="4,2,4",options="header"] |=== @@ -85,8 +85,6 @@ | link:multi-datasource-2pc/readme.adoc[Multi Datasource 2pc] (multi-datasource-2pc) | Database | An example showing how to work with Camel and Spring Boot using multiple pooled datasources with two-phase commit -| link:dynamic-router-eip/README.adoc[Dynamic Router Eip] (dynamic-router-eip) | EIP | Dynamic Router EIP component examples - | link:load-balancer-eip/README.adoc[Load Balancer Eip] (load-balancer-eip) | EIP | An example showing Load Balancer EIP with Camel and Spring Boot | link:resilience4j/README.adoc[Resilience4j] (resilience4j) | EIP | An example showing how to use Resilience4j EIP as circuit breaker in Camel routes
diff --git a/dynamic-router-eip/README.adoc b/dynamic-router-eip/README.adoc deleted file mode 100644 index 8b14715..0000000 --- a/dynamic-router-eip/README.adoc +++ /dev/null
@@ -1,152 +0,0 @@ -= Camel Dynamic Router EIP Component Spring Boot Examples - -This Camel Dynamic Router Spring Boot example module contains applications highlighting the two main use cases -of the Dynamic Router EIP component. - -== Single JVM Example - -This example shows how you can route messages within a single application, or JVM. - -=== Build the Single JVM Example - - mvn clean package -pl :camel-example-spring-boot-dynamic-router-eip-single - -=== Run the Single JVM Example - - mvn spring-boot:run -pl :camel-example-spring-boot-dynamic-router-eip-single - -==== Access the Swagger UI - -Next, point your browser to http://localhost:8080/dynamic-router-example/swagger-ui.html. Here, you will find -a single endpoint to interact with, called [.olive-background]#/generate#. Expand the section by clicking on -the colored bar, and click on the `Try it out` button. There is only one field to fill in, and that is the number -of messages that you want to send through the dynamic router. Enter a number, and then press the -[.blue-background]#Execute# button. You will see a `Loading` animation while the messages are being processed. - -== Multiple JVM (Multimodule) Example - -This example shows how you can route messages between separate modules, where each runs in its own JVM. - -=== Build the Multimodule Example - -==== For systems with Docker - - mvn clean package -f dynamic-router-eip-stack/pom.xml -Pdocker - -==== For systems with Podman - - mvn clean package -f dynamic-router-eip-stack/pom.xml -Ppodman - -On a system with Podman, your output might resemble the following: - -[source,text] ----- -Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg. ->>>> Executing external compose provider "/usr/bin/docker compose". Please refer to the documentation for details. <<<< - -[+] Running 6/6 - ✔ Network docker_test-dynamic-router Created 0.0s - ✔ Container broker Healthy 0.1s - ✔ Container main_router_service Healthy 0.1s - ✔ Container odd_numbers_service Started 0.1s - ✔ Container even_numbers_service Started 0.1s - ✔ Container all_numbers_service Started 0.1s ----- - -=== Run the Multimodule Example - -When running the application stack for the Multimodule example, it should be the same, whether you have -Docker or Podman installed. For Podman, please confirm that you have `podman compose` installed to ensure -that you can emulate the Docker CLI when using Podman. - - docker compose -f dynamic-router-eip-stack/project-resources/docker/compose.yaml up -d - -==== Access the Swagger UI - -Next, point your browser to http://localhost:8082/main-router/swagger-ui.html. Here, you will find a few -endpoints to interact with. - -===== Generate number messages - -The first endpoint is [.olive-background]#/generate#. Expand the section by clicking on the colored bar, and -click on the `Try it out` button. There is only one field to fill in, and that is the number of messages that -you want to send through the dynamic router. Enter a number, and then press the [.blue-background]#Execute# -button. You will see a `Loading` animation while the messages are being generated. This will be very brief, -since the message generation happens in its own thread, and everything at this point happens asynchronously. - -===== Retrieve number statistics - -From the moment messages begin to flow through the system, statistics are compiled. You can monitor the progress -by using the next endpoint: [.blue-background]#/counts#. Expand the section by clicking on the colored bar, and -click on the `Try it out` button. Click the [.blue-background]#Execute# button, and the current statistics will -be displayed. These will continue to count upward until the current batch of messages has completed. - -A run of one million messages might yield output that resembles the following: - -[source,json] ----- -{ - "all": 1000000, - "odd": 500000, - "elapsed seconds": 19, - "even": 500000 -} ----- - -===== View subscriber information - -This endpoint allows you to see the routing participants that have subscribed for dynamic routing. Expand the -endpoint for [.blue-background]#/list{channel}#. Clicking the `Try it out` button will allow you to enter the -channel name. For this example app, you should enter `numbers` in that field, and then click the -[.blue-background]#Execute# button. The returned text should look like this, although the formatting has been -altered for better documentation clarity: - -[source,text] ----- -[ - PrioritizedFilterProcessor [ - id: processAllNumbers, - priority: 5, - predicate: SpelExpression[ - #{headers.command == 'processNumber' or headers.command == 'resetStats'} - ], - endpoint: kafka://numbers_all?groupInstanceId=numbers_all_consumer&headerDeserializer=#stringValueHeaderDeserializer - ], - PrioritizedFilterProcessor [ - id: processEvenNumbers, - priority: 10, - predicate: SpelExpression[ - #{(headers.command == 'processNumber' and headers.number matches '\d*[02468]') or - headers.command == 'resetStats'} - ], - endpoint: kafka://numbers_even?groupInstanceId=numbers_even_consumer&headerDeserializer=#stringValueHeaderDeserializer - ], - PrioritizedFilterProcessor [ - id: processNumberStats, - priority: 10, - predicate: SpelExpression[ - #{headers.command == 'stats'} - ], - endpoint: kafka://main_router?groupInstanceId=main_router_consumer&headerDeserializer=#stringValueHeaderDeserializer - ], - PrioritizedFilterProcessor [ - id: processOddNumbers, - priority: 10, - predicate: SpelExpression[ - #{(headers.command == 'processNumber' and headers.number matches '\d*[13579]') or - headers.command == 'resetStats'} - ], - endpoint: kafka://numbers_odd?groupInstanceId=numbers_odd_consumer&headerDeserializer=#stringValueHeaderDeserializer - ] -] ----- - -== 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 please -https://camel.apache.org/community/contributing/[get involved] - -The Camel riders!
diff --git a/dynamic-router-eip/dynamic-router-eip-single/pom.xml b/dynamic-router-eip/dynamic-router-eip-single/pom.xml deleted file mode 100644 index 4d980d0..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/pom.xml +++ /dev/null
@@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-dynamic-router-eip</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-example-spring-boot-dynamic-router-eip-single</artifactId> - <packaging>jar</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples :: Single JVM Example</name> - <description>An example on how to use the Dynamic Router EIP component in a single Spring Boot application</description> - - <dependencies> - <dependency> - <groupId>org.springdoc</groupId> - <artifactId>springdoc-openapi-starter-webflux-ui</artifactId> - <version>${springdoc-version}</version> - </dependency> - </dependencies> -</project>
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/Application.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/Application.java deleted file mode 100644 index efc7fa5..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/Application.java +++ /dev/null
@@ -1,34 +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 org.apache.camel.example.springboot.numbers; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * We are so proud of our little Spring Boot Application. - */ -@SpringBootApplication(scanBasePackages = "org.apache.camel.example.springboot.numbers") -public class Application { - - /** - * Main method to start the application. Please make us proud. - */ - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/config/DynamicRouterComponentConfig.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/config/DynamicRouterComponentConfig.java deleted file mode 100644 index b81ead5..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/config/DynamicRouterComponentConfig.java +++ /dev/null
@@ -1,310 +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 org.apache.camel.example.springboot.numbers.config; - -import org.apache.camel.CamelContext; -import org.apache.camel.ConsumerTemplate; -import org.apache.camel.Predicate; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.example.springboot.numbers.participants.PredicateConstants; -import org.apache.camel.example.springboot.numbers.participants.RoutingParticipant; -import org.apache.camel.example.springboot.numbers.service.ResultsService; -import org.apache.camel.impl.engine.DefaultExecutorServiceManager; -import org.apache.camel.support.DefaultThreadPoolFactory; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.concurrent.ExecutorService; -import java.util.function.Function; - -import static org.apache.camel.component.dynamicrouter.routing.DynamicRouterConstants.COMPONENT_SCHEME_ROUTING; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_EIGHTS; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_EVEN; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_FIVES; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_FOURS; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_NINES; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_ODD; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_PRIMES; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_SEVENS; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_SIXES; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_TENS; -import static org.apache.camel.example.springboot.numbers.participants.PredicateConstants.PREDICATE_THREES; - -/** - * This configuration ingests the config properties in the application.yml file. - * Sets up the Camel route that feeds the Dynamic Router. Also creates all - * routing participants by using the various predicates defined in the - * {@link PredicateConstants} class. - */ -@Configuration -@EnableConfigurationProperties(ExampleConfig.class) -public class DynamicRouterComponentConfig { - - /** - * Holds the config properties. - */ - private final ExampleConfig exampleConfig; - - /** - * The Camel context. - */ - private final CamelContext camelContext; - - /** - * Create this config with the config properties object. - * - * @param exampleConfig the config properties object - */ - public DynamicRouterComponentConfig(final ExampleConfig exampleConfig, CamelContext camelContext) { - this.exampleConfig = exampleConfig; - this.camelContext = camelContext; - } - - private static final Function<ExampleConfig, String> createCommandUri = cfg -> - "%s:%s?recipientMode=%s&executorService=%s".formatted( - COMPONENT_SCHEME_ROUTING, - cfg.getRoutingChannel(), - cfg.getRecipientMode(), - "customPool"); - - @Bean - public ExecutorService customPool() { - DefaultThreadPoolFactory threadPoolFactory = new DefaultThreadPoolFactory(); - threadPoolFactory.setCamelContext(camelContext); - DefaultExecutorServiceManager executorServiceManager = new DefaultExecutorServiceManager(camelContext); - executorServiceManager.setThreadPoolFactory(threadPoolFactory); - return executorServiceManager.newCachedThreadPool(this, "DynamicRouterSpringBootThreadFactory"); - } - - /** - * Creates a simple route to allow a producer to send messages through - * the dynamic router. - */ - @Bean - RouteBuilder myRouter() { - return new RouteBuilder() { - @Override - public void configure() { - from(exampleConfig.getStartUri()).to(createCommandUri.apply(exampleConfig)); - } - }; - } - - @Bean - Predicate predicateTens() { - return PREDICATE_TENS; - } - - @Bean - Predicate predicateNines() { - return PREDICATE_NINES; - } - - @Bean - Predicate predicateEights() { - return PREDICATE_EIGHTS; - } - - @Bean - Predicate predicateSevens() { - return PREDICATE_SEVENS; - } - - @Bean - Predicate predicateSixes() { - return PREDICATE_SIXES; - } - - @Bean - Predicate predicateFives() { - return PREDICATE_FIVES; - } - - @Bean - Predicate predicateFours() { - return PREDICATE_FOURS; - } - - @Bean - Predicate predicateThrees() { - return PREDICATE_THREES; - } - - @Bean - Predicate predicateEven() { - return PREDICATE_EVEN; - } - - @Bean - Predicate predicateOdd() { - return PREDICATE_ODD; - } - - @Bean - Predicate predicatePrimes() { - return PREDICATE_PRIMES; - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 10. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant tensRoutingParticipant(final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "tens", 1, "predicateTens", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 9. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant ninesRoutingParticipant(final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "nines", 2, "predicateNines", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 8. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant eightsRoutingParticipant( - final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "eights", 3, "predicateEights", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 7. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant sevensRoutingParticipant( - final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "sevens", 4, "predicateSevens", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 6. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant sixesRoutingParticipant(final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "sixes", 5, "predicateSixes", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 5. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant fivesRoutingParticipant(final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "fives", 6, "predicateFives", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 4. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant foursRoutingParticipant(final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "fours", 7, "predicateFours", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a multiple of 3. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant threesRoutingParticipant( - final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "threes", 8, "predicateThrees", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * an even number. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant evensRoutingParticipant(final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "even", 9, "predicateEven", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * an odd number. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant oddsRoutingParticipant(final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "odd", 100, "predicateOdd", subscriberTemplate, resultsService); - } - - /** - * Create a {@link RoutingParticipant} that handles messages where the body comprises a number that is - * a prime. - * - * @param subscriberTemplate the {@link ConsumerTemplate} for subscribing to messages that match - * @param resultsService the service that handles the results of message processing - * @return the configured {@link RoutingParticipant} - */ - @Bean - RoutingParticipant primesRoutingParticipant( - final ProducerTemplate subscriberTemplate, final ResultsService resultsService) { - return new RoutingParticipant(exampleConfig, "primes", 10, "predicatePrimes", subscriberTemplate, resultsService); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/config/ExampleConfig.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/config/ExampleConfig.java deleted file mode 100644 index ed1fc38..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/config/ExampleConfig.java +++ /dev/null
@@ -1,124 +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 org.apache.camel.example.springboot.numbers.config; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * The config properties object from the application.yml file. - */ -@ConfigurationProperties(prefix = "camel.spring-boot.example.dynamic-router-eip") -public class ExampleConfig { - - /** - * The dynamic router channel. - */ - private String routingChannel; - - /** - * The dynamic router control channel URI - */ - private String subscribeUri; - - /** - * The scheme that routing participants will use to listen for messages. - */ - private String receiverScheme; - - /** - * The URI where messages will be sent to as the starting point for the - * route that feeds the dynamic router. - */ - private String startUri; - - /** - * The recipient mode -- first matching filter only, or all matching filters. - */ - private String recipientMode; - - /** - * The number of messages to send. - */ - private int sendMessageCount; - - /** - * The URI where messages will be sent to as the starting point for the - * route that feeds the dynamic router. - */ - public String getStartUri() { - return startUri; - } - - public void setStartUri(String startUri) { - this.startUri = startUri; - } - - /** - * The dynamic router channel. - */ - public String getRoutingChannel() { - return routingChannel; - } - - public void setRoutingChannel(String routingChannel) { - this.routingChannel = routingChannel; - } - - /** - * The dynamic router control channel URI - */ - public String getSubscribeUri() { - return subscribeUri; - } - - public void setSubscribeUri(String subscribeUri) { - this.subscribeUri = subscribeUri; - } - - /** - * The scheme that routing participants will use to listen for messages. - */ - public String getReceiverScheme() { - return receiverScheme; - } - - public void setReceiverScheme(String receiverScheme) { - this.receiverScheme = receiverScheme; - } - - /** - * The recipient mode -- first matching filter only, or all matching filters. - */ - public String getRecipientMode() { - return this.recipientMode; - } - - public void setRecipientMode(String recipientMode) { - this.recipientMode = recipientMode; - } - - /** - * The number of messages to send. - */ - public int getSendMessageCount() { - return sendMessageCount; - } - - public void setSendMessageCount(int sendMessageCount) { - this.sendMessageCount = sendMessageCount; - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/participants/PredicateConstants.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/participants/PredicateConstants.java deleted file mode 100644 index 9db8f92..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/participants/PredicateConstants.java +++ /dev/null
@@ -1,129 +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 org.apache.camel.example.springboot.numbers.participants; - -import org.apache.camel.Exchange; -import org.apache.camel.Predicate; - -import java.util.function.BiPredicate; -import java.util.function.Function; -import java.util.function.IntFunction; -import java.util.function.ToIntFunction; - -/** - * Provides various {@link Predicate}s that routing participants can send to the - * dynamic router as rules to determine exchange suitability. - */ -public final class PredicateConstants { - - private PredicateConstants() { - throw new UnsupportedOperationException("Utility class should not be instantiated"); - } - - /** - * Gets the message body as an integer and determines if the number is evenly - * divided by the supplied integer. - */ - public static final BiPredicate<Integer, Integer> noRemainder = (n, m) -> n % m == 0; - - /** - * Extracts the number from the exchange header. - */ - public static final ToIntFunction<Exchange> extractValue = e -> - e.getMessage().getHeader("number", Integer.class); - - public static final IntFunction<Predicate> noRemainderCurried = m -> - e -> noRemainder.test(extractValue.applyAsInt(e), m); - - /** - * Determines if the message body is a number that is even. - */ - public static final Predicate PREDICATE_EVEN = e -> noRemainderCurried.apply(2).matches(e); - - /** - * Determines if the message body is a number that is odd. - */ - public static final Predicate PREDICATE_ODD = e -> !noRemainderCurried.apply(2).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 3. - */ - public static final Predicate PREDICATE_THREES = e -> noRemainderCurried.apply(3).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 4. - */ - public static final Predicate PREDICATE_FOURS = e -> noRemainderCurried.apply(4).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 5. - */ - public static final Predicate PREDICATE_FIVES = e -> noRemainderCurried.apply(5).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 6. - */ - public static final Predicate PREDICATE_SIXES = e -> noRemainderCurried.apply(6).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 7. - */ - public static final Predicate PREDICATE_SEVENS = e -> noRemainderCurried.apply(7).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 8. - */ - public static final Predicate PREDICATE_EIGHTS = e -> noRemainderCurried.apply(8).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 9. - */ - public static final Predicate PREDICATE_NINES = e -> noRemainderCurried.apply(9).matches(e); - - /** - * Determines if the message body is a number that is a multiple of 10. - */ - public static final Predicate PREDICATE_TENS = e -> noRemainderCurried.apply(10).matches(e); - - /** - * If this predicate is prioritized with a higher number than {@link #PREDICATE_SEVENS} - * or {@link #PREDICATE_THREES} or {@link #PREDICATE_EVEN}, then this will miss 7, 3, - * and 2 in the accumulated list of prime numbers. - */ - public static final Predicate PREDICATE_PRIMES = e -> { - int n = extractValue.applyAsInt(e); - if (n <= 0) { - return false; - } - // handle cases for 1, 2 and 3 - if (n <= 3) { - return n > 1; - } - // check if number is divisible by 2 or 3 - if (noRemainder.test(n, 2) || noRemainder.test(n, 3)) { - return false; - } - int i = 5; - while (i * i <= n) { - if (noRemainder.test(n, i) || noRemainder.test(n, (i + 2))) { - return false; - } - i += 6; - } - return true; - }; -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/participants/RoutingParticipant.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/participants/RoutingParticipant.java deleted file mode 100644 index 62c9025..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/participants/RoutingParticipant.java +++ /dev/null
@@ -1,176 +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 org.apache.camel.example.springboot.numbers.participants; - -import org.apache.camel.Consume; -import org.apache.camel.Predicate; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.dynamicrouter.control.DynamicRouterControlMessage; -import org.apache.camel.example.springboot.numbers.config.ExampleConfig; -import org.apache.camel.example.springboot.numbers.service.ResultsService; - -/** - * A dynamic routing participant that knows how to build a control channel message - * for subscribing to dynamic router content. A provided subscribe URI will allow - * an instance to consume messages sent to that URI. Results are sent to the - * results service instance. - */ -public class RoutingParticipant { - - /** - * Name of the dynamic router channel for an implementation to create a - * subscription for. - */ - protected final String routingChannel; - - /** - * The dynamic router control channel URI where subscribe messages will - * be sent. - */ - protected final String subscribeUri; - - /** - * For consuming messages that fit an implementation's rules, this is the - * scheme/component that the participant will listen on and consume from. - */ - protected final String receiverScheme; - - /** - * The "bin" or "category" of messages for a participant implementation. - * This value is also used along with the {@link #receiverScheme} to - * create the {@link #consumeUri}. - */ - protected final String bin; - - /** - * The priority of the processor when evaluated by the dynamic router. Lower - * number means higher priority. - */ - protected final int priority; - - /** - * The name of the {@link Predicate} by which exchanges are evaluated for suitability for - * a routing participant. - */ - protected final String predicate; - - /** - * The URI that a participant implementation will listen on for messages - * that match its rules. - */ - protected final String consumeUri; - - /** - * The {@link ProducerTemplate} to send subscriber messages to the dynamic - * router control channel. - */ - protected final ProducerTemplate subscriberTemplate; - - /** - * The service that accumulates results of dynamic routing from each - * participant. - */ - protected final ResultsService resultsService; - - public RoutingParticipant( - final ExampleConfig config, - final String bin, - final int priority, - final String predicate, - final ProducerTemplate subscriberTemplate, - final ResultsService resultsService) { - this.bin = bin; - this.priority = priority; - this.predicate = predicate; - this.routingChannel = config.getRoutingChannel(); - this.subscribeUri = config.getSubscribeUri(); - this.receiverScheme = config.getReceiverScheme(); - this.consumeUri = receiverScheme + ":" + bin; - this.subscriberTemplate = subscriberTemplate; - this.resultsService = resultsService; - } - - /** - * This method consumes messages that have matched the participant's rules - * and have been routed to the participant. It adds the results to the - * results service. - * - * @param number the numeric message body that is received - */ - @Consume(property = "consumeUri") - public void consumeMessage(final int number) { - resultsService.addResult(bin, number); - } - - /** - * Gets the consumer URI. - * - * @return the consumer URI - */ - public String getConsumeUri() { - return this.consumeUri; - } - - /** - * Sends the subscribe message to the dynamic router control channel. - */ - public void subscribe() { - subscriberTemplate.sendBody(subscribeUri, createSubscribeMessage()); - } - - /** - * Gets the bin / category. - * - * @return the bin / category - */ - protected String getBin() { - return bin; - } - - /** - * Gets the implementation's rule priority. - * - * @return the rule priority - */ - protected int getPriority() { - return priority; - } - - /** - * The name of the implementation's rule as a {@link Predicate}. - * @return the {@link Predicate} rule name - */ - protected String getPredicate() { - return predicate; - } - - /** - * Create a {@link DynamicRouterControlMessage} based on parameters from the - * implementing class. - * - * @return the {@link DynamicRouterControlMessage} - */ - protected DynamicRouterControlMessage createSubscribeMessage() { - return DynamicRouterControlMessage.Builder.newBuilder() - .subscriptionId(getBin()) - .subscribeChannel(routingChannel) - .priority(getPriority()) - .destinationUri(getConsumeUri()) - .predicateBean(getPredicate()) - .build(); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/service/NumbersService.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/service/NumbersService.java deleted file mode 100644 index 4fed466..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/service/NumbersService.java +++ /dev/null
@@ -1,143 +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 org.apache.camel.example.springboot.numbers.service; - -import org.apache.camel.Produce; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.config.ExampleConfig; -import org.apache.camel.example.springboot.numbers.participants.RoutingParticipant; -import org.apache.camel.util.StopWatch; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; - -import java.util.List; -import java.util.concurrent.CountDownLatch; - -import static java.util.concurrent.TimeUnit.MINUTES; - -/** - * Create numbers and send them to the dynamic router so that they can be - * processed and binned to demonstrate the usage of the dynamic router - * component. - */ -@Service -public class NumbersService { - - private static final Logger LOG = LoggerFactory.getLogger(NumbersService.class); - - /** - * The URI to send the messages to. This URI feeds the dynamic router in a - * Camel route. - */ - private final String startUri; - - /** - * The routing participants that have subscribed to routing and have - * provided their rules for suitable exchanges. - */ - private final List<RoutingParticipant> participants; - - /** - * The {@link ProducerTemplate} to start the messages on the route. - */ - @Produce(property = "startUri") - private final ProducerTemplate start; - - /** - * The service that contains participants' results of processing the - * messages that they have received. - */ - private final ResultsService resultsService; - - /** - * The {@link CountDownLatch} to wait for the total expected number of - * messages to be received. - */ - private CountDownLatch countDownLatch; - - /** - * The number of messages to generate. - */ - final int numberOfMessages; - - /** - * Create this service with everything. - * - * @param config the configuration object representing the config properties - * @param participants the dynamic router participants - * @param start the producer template to send messages to the start endpoint - * @param resultsService the service that compiles routing results - */ - public NumbersService( - final ExampleConfig config, - final List<RoutingParticipant> participants, - final ProducerTemplate start, - final ResultsService resultsService) { - this.startUri = config.getStartUri(); - this.participants = participants; - this.start = start; - this.resultsService = resultsService; - this.numberOfMessages = config.getSendMessageCount(); - } - - /** - * After the application is started and ready, tell each routing - * participant to subscribe, and then send the messages. Afterward, - * display the results and exit the app. - */ - public String start(int limit) throws InterruptedException { - resultsService.resetStatistics(); - LOG.info("Subscribing {} participants", participants.size()); - participants.forEach(RoutingParticipant::subscribe); - countDownLatch = new CountDownLatch(1); - final StopWatch watch = new StopWatch(); - LOG.info("Sending {} messages to the dynamic router: {}", limit, getStartUri()); - Mono<Integer> msgFlux = sendMessages(limit); - msgFlux.subscribe(); - if (!countDownLatch.await(1, MINUTES)) { - LOG.warn("Statistics may be inaccurate, since the operation timed out"); - } - return resultsService.getStatistics(watch, limit); - } - - /** - * Sends the messages to the starting endpoint of the route. - * - * @return an empty Mono - */ - public Mono<Integer> sendMessages(int limit) { - return Flux.range(1, limit) - .parallel() - .runOn(Schedulers.boundedElastic()) - .doOnNext(n -> start.sendBodyAndHeader(n, "number", n)) - .reduce((a, b) -> b) - .doFinally(signal -> countDownLatch.countDown()); - } - - /** - * Gets the starting endpoint of the route. - * - * @return the starting endpoint of the route. - */ - public String getStartUri() { - return startUri; - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/service/ResultsService.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/service/ResultsService.java deleted file mode 100644 index 292994d..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/service/ResultsService.java +++ /dev/null
@@ -1,101 +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 org.apache.camel.example.springboot.numbers.service; - -import org.apache.camel.util.StopWatch; -import org.springframework.stereotype.Service; - -import java.text.NumberFormat; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentSkipListMap; -import java.util.concurrent.ConcurrentSkipListSet; - -/** - * Holds processing results so that they can be displayed, etc. - */ -@Service -public class ResultsService { - - private final NumberFormat numberFormat = NumberFormat.getIntegerInstance(); - - /** - * A map of the "bin" or "category" to the list of values in that bin. - */ - private final ConcurrentSkipListMap<String, ConcurrentSkipListSet<Integer>> results; - - /** - * Create the service and initialize the results map. - */ - public ResultsService() { - this.results = new ConcurrentSkipListMap<>(); - } - - /** - * Add a result value for the given key/bin. - * - * @param key the bin or category - * @param value the value to add to the bin - */ - public void addResult(final String key, int value) { - results.computeIfAbsent(key, v -> new ConcurrentSkipListSet<>()).add(value); - } - - /** - * Get the results map. - * - * @return the results map - */ - public Map<String, ConcurrentSkipListSet<Integer>> getResults() { - return results; - } - - public void resetStatistics() { - results.clear(); - } - - /** - * Get a message that contains the statistics of the messaging. - * - * @param watch a {@link StopWatch} that was started at the beginning of messaging - * @return a message that contains the statistics of the messaging - */ - public String getStatistics(final StopWatch watch, int numberSent) { - final long taken = watch.taken(); - final int totalCount = getResults().values() - .stream() - .mapToInt(Collection::size) - .sum(); - final int numberLength = numberFormat.format(totalCount).length(); - StringBuilder statistics = new StringBuilder("Finished in ") - .append(taken).append("ms") - .append("\nDynamic Router Spring Boot Numbers Example Results:\n"); - getResults().entrySet().stream() - .sorted((o1, o2) -> o2.getValue().size() - o1.getValue().size()) - .map(e -> String.format("%7s: %" + numberLength + "s [%3d%% routed, %3d%% sent]", // NOSONAR - e.getKey(), numberFormat.format(e.getValue().size()), - e.getValue().size() * 100 / totalCount, - e.getValue().size() * 100 / numberSent)) - .forEach(s -> statistics.append("\n\t").append(s)); - statistics.append("\n\n\t") - .append(String.format("%7s: %" + numberLength + "s [%3d%% routed, %3d%% sent]", // NOSONAR - "total", numberFormat.format(totalCount), - totalCount * 100 / totalCount, - totalCount * 100 / numberSent)); - return statistics.toString(); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/web/NumbersController.java b/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/web/NumbersController.java deleted file mode 100644 index 8cab95a..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/java/org/apache/camel/example/springboot/numbers/web/NumbersController.java +++ /dev/null
@@ -1,22 +0,0 @@ -package org.apache.camel.example.springboot.numbers.web; - -import org.apache.camel.example.springboot.numbers.service.NumbersService; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -@RestController -public class NumbersController { - - private final NumbersService numbersService; - - public NumbersController(NumbersService numbersService) { - this.numbersService = numbersService; - } - - @PutMapping(path = "/generate") - public Mono<String> generate(@RequestParam("limit") int limit) throws InterruptedException { - return Mono.just(numbersService.start(limit)); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/resources/application.yml b/dynamic-router-eip/dynamic-router-eip-single/src/main/resources/application.yml deleted file mode 100644 index 4986e6e..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/resources/application.yml +++ /dev/null
@@ -1,46 +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. -# -camel: - springboot: - name: CamelSpringBootDynamicRouterExample - jmx-enabled: false - shutdown-timeout: 30 - endpoint-bridge-error-handler: true - spring-boot: - example: - dynamic-router-eip: - routing-channel: numbers - subscribe-uri: dynamic-router-control:subscribe - receiver-scheme: direct - start-uri: direct:start - recipient-mode: firstMatch - component: - dynamic-router: - lazy-start-producer: true -logging: - level: - root: WARN - org.apache.camel.example.springboot: INFO -spring: - profiles: - active: default - application: - name: CamelSpringBootDynamicRouterExample - webflux: - base-path: "/dynamic-router-example" -server: - port: 8080
diff --git a/dynamic-router-eip/dynamic-router-eip-single/src/main/resources/logback.xml b/dynamic-router-eip/dynamic-router-eip-single/src/main/resources/logback.xml deleted file mode 100644 index ab86d43..0000000 --- a/dynamic-router-eip/dynamic-router-eip-single/src/main/resources/logback.xml +++ /dev/null
@@ -1,12 +0,0 @@ -<configuration> - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> - <encoder> - <pattern>%8.8relative %highlight(%5.-5level) %15.-15c{0} - %m%n</pattern> - </encoder> - </appender> - <root level="error"> - <appender-ref ref="STDOUT"/> - </root> - <logger name="org.apache.camel.example.springboot.numbers.Application" level="warn"/> - <logger name="org.apache.camel.example.springboot" level="info"/> -</configuration>
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/pom.xml b/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/pom.xml deleted file mode 100644 index 4599939..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/pom.xml +++ /dev/null
@@ -1,41 +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. - --> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://maven.apache.org/POM/4.0.0" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-dynamic-router-eip-stack</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>all-numbers-service</artifactId> - <packaging>jar</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples :: Multimodule :: All Numbers Service</name> - - <dependencies> - <dependency> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>numbers-common</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - -</project> \ No newline at end of file
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/all/Application.java b/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/all/Application.java deleted file mode 100644 index 973d7f5..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/all/Application.java +++ /dev/null
@@ -1,33 +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 org.apache.camel.example.springboot.numbers.all; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableScheduling; - -@EnableScheduling -@SpringBootApplication(scanBasePackages = "org.apache.camel.example.springboot.numbers") -public class Application { - - /** - * Main method to start the application. Please make us proud. - */ - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/all/service/ProcessAllNumbersRoutingParticipant.java b/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/all/service/ProcessAllNumbersRoutingParticipant.java deleted file mode 100644 index 11c02a0..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/all/service/ProcessAllNumbersRoutingParticipant.java +++ /dev/null
@@ -1,43 +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 org.apache.camel.example.springboot.numbers.all.service; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.common.service.ProcessNumbersRoutingParticipant; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -@Service -public class ProcessAllNumbersRoutingParticipant extends ProcessNumbersRoutingParticipant { - - public ProcessAllNumbersRoutingParticipant( - @Value("${number-generator.subscribe-uri}") String subscribeUri, - @Value("${number-generator.routing-channel}") String routingChannel, - @Value("${number-generator.predicate}") String predicate, - @Value("${number-generator.expression-language}") String expressionLanguage, - @Value("${number-generator.subscription-priority}") int subscriptionPriority, - @Value("${number-generator.consume-uri}") String consumeUri, - @Value("${number-generator.command-uri}") String commandUri, - ProducerTemplate producerTemplate, - CamelContext camelContext) { - super("all", "processAllNumbers", subscribeUri, routingChannel, subscriptionPriority, - predicate, expressionLanguage, consumeUri, commandUri, producerTemplate, camelContext); - - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/resources/application.yaml b/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/resources/application.yaml deleted file mode 100644 index b4766ab..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/all-numbers-service/src/main/resources/application.yaml +++ /dev/null
@@ -1,22 +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. -# -app: - name: "all-numbers" - port: 8911 - id: "numbers_all" - predicate: "{headers.command == 'processNumber' or headers.command == 'resetStats'}" - priority: 5
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/pom.xml b/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/pom.xml deleted file mode 100644 index 48c5bd8..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/pom.xml +++ /dev/null
@@ -1,41 +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. - --> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://maven.apache.org/POM/4.0.0" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-dynamic-router-eip-stack</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>even-numbers-service</artifactId> - <packaging>jar</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples :: Multimodule :: Even Numbers Service</name> - - <dependencies> - <dependency> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>numbers-common</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - -</project> \ No newline at end of file
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/even/Application.java b/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/even/Application.java deleted file mode 100644 index 201c4f8..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/even/Application.java +++ /dev/null
@@ -1,31 +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 org.apache.camel.example.springboot.numbers.even; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication(scanBasePackages = "org.apache.camel.example.springboot.numbers") -public class Application { - - /** - * Main method to start the application. Please make us proud. - */ - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/even/service/ProcessEvenNumbersRoutingParticipant.java b/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/even/service/ProcessEvenNumbersRoutingParticipant.java deleted file mode 100644 index e5e0712..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/even/service/ProcessEvenNumbersRoutingParticipant.java +++ /dev/null
@@ -1,42 +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 org.apache.camel.example.springboot.numbers.even.service; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.common.service.ProcessNumbersRoutingParticipant; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -@Service -public class ProcessEvenNumbersRoutingParticipant extends ProcessNumbersRoutingParticipant { - - public ProcessEvenNumbersRoutingParticipant( - @Value("${number-generator.subscribe-uri}") String subscribeUri, - @Value("${number-generator.routing-channel}") String routingChannel, - @Value("${number-generator.predicate}") String predicate, - @Value("${number-generator.expression-language}") String expressionLanguage, - @Value("${number-generator.subscription-priority}") int subscriptionPriority, - @Value("${number-generator.consume-uri}") String consumeUri, - @Value("${number-generator.command-uri}") String commandUri, - ProducerTemplate producerTemplate, - CamelContext camelContext) { - super("even", "processEvenNumbers", subscribeUri, routingChannel, subscriptionPriority, - predicate, expressionLanguage, consumeUri, commandUri, producerTemplate, camelContext); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/resources/application.yaml b/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/resources/application.yaml deleted file mode 100644 index 9074dc4..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/even-numbers-service/src/main/resources/application.yaml +++ /dev/null
@@ -1,22 +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. -# -app: - name: "even-numbers" - port: 8902 - id: "numbers_even" - predicate: "{(headers.command == 'processNumber' and headers.number matches '\\d*[02468]') or headers.command == 'resetStats'}" - priority: 10
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/pom.xml b/dynamic-router-eip/dynamic-router-eip-stack/main-router/pom.xml deleted file mode 100644 index 94ded85..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/pom.xml +++ /dev/null
@@ -1,72 +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. - --> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://maven.apache.org/POM/4.0.0" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-dynamic-router-eip-stack</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>main-router</artifactId> - <packaging>jar</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples :: Multimodule :: Main Router Service</name> - - <dependencies> - <dependency> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>numbers-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.springdoc</groupId> - <artifactId>springdoc-openapi-starter-webflux-ui</artifactId> - <version>${springdoc-version}</version> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-validation</artifactId> - </dependency> - </dependencies> - - - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <executions> - <!-- - This can be removed when AOT processing is - compatible with spring statemachine - --> - <execution> - <id>process-aot</id> - <configuration> - <skip>true</skip> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/Application.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/Application.java deleted file mode 100644 index cdcef72..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/Application.java +++ /dev/null
@@ -1,31 +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 org.apache.camel.example.springboot.numbers.mainrouter; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication(scanBasePackages = "org.apache.camel.example.springboot.numbers") -public class Application { - - /** - * Main method to start the application. Please make us proud. - */ - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/DynamicRouterComponentConfig.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/DynamicRouterComponentConfig.java deleted file mode 100644 index 403080e..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/DynamicRouterComponentConfig.java +++ /dev/null
@@ -1,39 +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 org.apache.camel.example.springboot.numbers.mainrouter.config; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.Pattern; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.validation.annotation.Validated; - -import static org.apache.camel.component.dynamicrouter.routing.DynamicRouterConstants.MODE_ALL_MATCH; -import static org.apache.camel.component.dynamicrouter.routing.DynamicRouterConstants.MODE_FIRST_MATCH; - -/** - * @param routingChannel The dynamic router channel. - * @param recipientMode The recipient mode -- first matching filter only, or all matching filters. - */ -@Validated -@ConfigurationProperties(prefix = "main-router.dynamic-router-component") -public record DynamicRouterComponentConfig( - - @NotBlank String routingChannel, - - @NotBlank @Pattern(regexp = "^" + MODE_FIRST_MATCH + "|" + MODE_ALL_MATCH + "$") String recipientMode) { -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/MainRouterConfig.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/MainRouterConfig.java deleted file mode 100644 index 2cc4cfd..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/MainRouterConfig.java +++ /dev/null
@@ -1,184 +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 org.apache.camel.example.springboot.numbers.mainrouter.config; - -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.LoggingLevel; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.dynamicrouter.control.DynamicRouterControlMessage; -import org.apache.camel.example.springboot.numbers.mainrouter.model.StateMachineEvent; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events; -import org.apache.camel.impl.engine.DefaultExecutorServiceManager; -import org.apache.camel.support.DefaultThreadPoolFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.MessageBuilder; - -import java.util.concurrent.ExecutorService; -import java.util.function.Function; - -import static org.apache.camel.component.dynamicrouter.control.DynamicRouterControlConstants.COMPONENT_SCHEME_CONTROL; -import static org.apache.camel.component.dynamicrouter.control.DynamicRouterControlConstants.CONTROL_ACTION_LIST; -import static org.apache.camel.component.dynamicrouter.control.DynamicRouterControlConstants.CONTROL_ACTION_SUBSCRIBE; -import static org.apache.camel.component.dynamicrouter.routing.DynamicRouterConstants.COMPONENT_SCHEME_ROUTING; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.ENDPOINT_DIRECT_COMMAND; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.ENDPOINT_DIRECT_LIST; -import static org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events.PARTICIPANT_SUBSCRIBED; - -/** - * This configuration ingests the config properties in the application.yml file. - * Sets up the Camel route that feeds the Dynamic Router. - */ -@Configuration -@EnableConfigurationProperties(DynamicRouterComponentConfig.class) -public class MainRouterConfig { - - /** - * Holds the config exchange.properties. - */ - private final DynamicRouterComponentConfig dynamicRouterComponentConfig; - - /** - * URI for sending command messages. - */ - private final String commandUri; - - /** - * URI for the dynamic router to send messages to. - */ - private final String subscribeUri; - - /** - * The Camel context. - */ - private final CamelContext camelContext; - - /** - * For publishing events. - */ - final ApplicationEventPublisher eventPublisher; - - /** - * Create this config with the config properties object. - * - * @param dynamicRouterComponentConfig the config properties object - * @param camelContext the Camel context - */ - public MainRouterConfig(final DynamicRouterComponentConfig dynamicRouterComponentConfig, - @Value("${number-generator.command-uri}") String commandUri, - @Value("${number-generator.subscribe-uri}") String subscribeUri, - final CamelContext camelContext, - final ApplicationEventPublisher eventPublisher) { - this.dynamicRouterComponentConfig = dynamicRouterComponentConfig; - this.commandUri = commandUri; - this.subscribeUri = subscribeUri; - this.camelContext = camelContext; - this.eventPublisher = eventPublisher; - } - - private static final Function<DynamicRouterComponentConfig, String> createCommandUri = cfg -> - "%s:%s?recipientMode=%s&executorService=%s".formatted( - COMPONENT_SCHEME_ROUTING, - cfg.routingChannel(), - cfg.recipientMode(), - "customPool"); - - @Bean - ObjectMapper objectMapper() { - return new ObjectMapper(new JsonFactory()); - } - - @Bean - public ExecutorService customPool() { - DefaultThreadPoolFactory threadPoolFactory = new DefaultThreadPoolFactory(); - threadPoolFactory.setCamelContext(camelContext); - DefaultExecutorServiceManager executorServiceManager = new DefaultExecutorServiceManager(camelContext); - executorServiceManager.setThreadPoolFactory(threadPoolFactory); - return executorServiceManager.newCachedThreadPool(this, "DynamicRouterSpringBootThreadFactory"); - } - - /** - * Creates a simple route to allow a producer to send messages through - * the dynamic router on the routing channel. - */ - @Bean - RouteBuilder numbersRouter() { - return new RouteBuilder(camelContext) { - @Override - public void configure() { - from(commandUri).to(createCommandUri.apply(dynamicRouterComponentConfig)); - } - }; - } - - /** - * Creates a simple route to allow a producer to send messages through - * the dynamic router on the routing channel. - */ - @Bean - RouteBuilder directCommandRouter() { - return new RouteBuilder(camelContext) { - @Override - public void configure() { - from(ENDPOINT_DIRECT_COMMAND).to(createCommandUri.apply(dynamicRouterComponentConfig)); - } - }; - } - - /** - * Creates a simple route to allow a producer to send messages through - * the dynamic router on the routing channel. - */ - @Bean - RouteBuilder listSubscribersRouter() { - return new RouteBuilder(camelContext) { - @Override - public void configure() { - from(ENDPOINT_DIRECT_LIST) - .toD(COMPONENT_SCHEME_CONTROL + ":" + CONTROL_ACTION_LIST + - "?subscribeChannel=${header.subscribeChannel}"); - } - }; - } - - /** - * Creates a simple route to allow dynamic routing participants to - * subscribe or unsubscribe. - */ - @Bean - RouteBuilder subscriptionRouter() { - return new RouteBuilder(camelContext) { - @Override - public void configure() { - from(subscribeUri) - .log(LoggingLevel.INFO, MainRouterConfig.class.getCanonicalName(), "Processing subscription: ${body}") - .unmarshal().json(DynamicRouterControlMessage.class) - .process(exchange -> { - Message<Events> message = MessageBuilder.withPayload(PARTICIPANT_SUBSCRIBED).build(); - eventPublisher.publishEvent(new StateMachineEvent(this, message)); - }) - .to(COMPONENT_SCHEME_CONTROL + ":" + CONTROL_ACTION_SUBSCRIBE); - } - }; - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/StateMachineActionConfig.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/StateMachineActionConfig.java deleted file mode 100644 index deb67ab..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/StateMachineActionConfig.java +++ /dev/null
@@ -1,73 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.config; - -import org.apache.camel.example.springboot.numbers.mainrouter.service.NumberGeneratorService; -import org.apache.camel.example.springboot.numbers.mainrouter.service.NumberStatisticsService; -import org.apache.camel.example.springboot.numbers.mainrouter.service.WarmUpService; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.States; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.listener.StateMachineListener; -import org.springframework.statemachine.listener.StateMachineListenerAdapter; -import org.springframework.statemachine.state.State; - -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; - -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_EVENT_LIMIT; - -@Configuration -public class StateMachineActionConfig { - - private static final Logger LOG = LoggerFactory.getLogger(StateMachineActionConfig.class); - - private final WarmUpService warmUpService; - - private final NumberGeneratorService numberGeneratorService; - - private final NumberStatisticsService numberStatisticsService; - - public StateMachineActionConfig(WarmUpService warmUpService, NumberGeneratorService numberGeneratorService, NumberStatisticsService numberStatisticsService) { - this.warmUpService = warmUpService; - this.numberGeneratorService = numberGeneratorService; - this.numberStatisticsService = numberStatisticsService; - } - - @Bean - public StateMachineListener<States, Events> listener() { - return new StateMachineListenerAdapter<>() { - @Override - public void stateChanged(State<States, Events> from, State<States, Events> to) { - LOG.info("State changed from '{}' to '{}'", - from == null ? "none" : from.getId(), - to.getId()); - } - }; - } - - @Bean - public Action<States, Events> warmUpAction() { - return context -> { - ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); - executor.schedule(warmUpService::doWarmUp, 2, TimeUnit.SECONDS); - executor.shutdown(); - }; - } - - @Bean - public Action<States, Events> generateNumbersAction() { - return context -> { - int limit = (int) context.getMessageHeader(HEADER_EVENT_LIMIT); - numberGeneratorService.generateNumbers(limit); - }; - } - - @Bean - public Action<States, Events> resetStatisticsAction() { - return context -> numberStatisticsService.resetStats(); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/StateMachineConfig.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/StateMachineConfig.java deleted file mode 100644 index 9748391..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/config/StateMachineConfig.java +++ /dev/null
@@ -1,89 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.config; - -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.States; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Configuration; -import org.springframework.statemachine.action.Action; -import org.springframework.statemachine.config.EnableStateMachine; -import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter; -import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer; -import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; -import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; -import org.springframework.statemachine.listener.StateMachineListener; - -import java.util.EnumSet; - -@Configuration -@EnableStateMachine -public class StateMachineConfig extends EnumStateMachineConfigurerAdapter<States, Events> { - - private final StateMachineListener<States, Events> listener; - - private final Action<States, Events> warmUpAction; - - private final Action<States, Events> generateNumbersAction; - - private final Action<States, Events> resetStatisticsAction; - - private boolean initialized = false; - - public StateMachineConfig(StateMachineListener<States, Events> listener, - @Qualifier("warmUpAction") Action<States, Events> warmUpAction, - @Qualifier("generateNumbersAction") Action<States, Events> generateNumbersAction, - @Qualifier("resetStatisticsAction") Action<States, Events> resetStatisticsAction) { - this.listener = listener; - this.warmUpAction = warmUpAction; - this.generateNumbersAction = generateNumbersAction; - this.resetStatisticsAction = resetStatisticsAction; - } - - @Override - public void configure(StateMachineConfigurationConfigurer<States, Events> config) throws Exception { - config - .withConfiguration() - .autoStartup(true) - .listener(listener); - } - - @Override - public void configure(StateMachineStateConfigurer<States, Events> states) throws Exception { - states - .withStates() - .initial(States.STARTING) - .states(EnumSet.allOf(States.class)); - } - - @Override - public void configure(StateMachineTransitionConfigurer<States, Events> transitions) throws Exception { - // @formatter:off - transitions - .withExternal() - .source(States.STARTING) - .target(States.INITIALIZING) - .event(Events.PARTICIPANT_SUBSCRIBED) - .guard(context -> !initialized) - .action(context -> initialized = true) - .action(resetStatisticsAction) - .action(warmUpAction) - .and() - .withExternal() - .source(States.INITIALIZING) - .target(States.READY) - .event(Events.INITIALIZATION_COMPLETE) - .action(resetStatisticsAction) - .and() - .withExternal() - .source(States.READY) - .target(States.GENERATING_NUMBERS) - .event(Events.GENERATE_NUMBERS_STARTED) - .action(resetStatisticsAction) - .action(generateNumbersAction) - .and() - .withExternal() - .source(States.GENERATING_NUMBERS) - .target(States.READY) - .event(Events.GENERATE_NUMBERS_COMPLETE); - // @formatter:on - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/model/StateMachineEvent.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/model/StateMachineEvent.java deleted file mode 100644 index 2075f74..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/model/StateMachineEvent.java +++ /dev/null
@@ -1,19 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.model; - -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events; -import org.springframework.context.ApplicationEvent; -import org.springframework.messaging.Message; - -public class StateMachineEvent extends ApplicationEvent { - - private final transient Message<Events> message; - - public StateMachineEvent(Object source, Message<Events> message) { - super(source); - this.message = message; - } - - public Message<Events> getMessage() { - return message; - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/routing/NumberStatisticsRoutingParticipant.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/routing/NumberStatisticsRoutingParticipant.java deleted file mode 100644 index eb489b3..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/routing/NumberStatisticsRoutingParticipant.java +++ /dev/null
@@ -1,75 +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 org.apache.camel.example.springboot.numbers.mainrouter.routing; - -import org.apache.camel.CamelContext; -import org.apache.camel.Consume; -import org.apache.camel.Header; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.dynamicrouter.control.DynamicRouterControlMessage; -import org.apache.camel.example.springboot.numbers.common.service.RoutingParticipant; -import org.apache.camel.example.springboot.numbers.mainrouter.service.NumberStatisticsService; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import static org.apache.camel.component.dynamicrouter.control.DynamicRouterControlConstants.COMPONENT_SCHEME_CONTROL; -import static org.apache.camel.component.dynamicrouter.control.DynamicRouterControlConstants.CONTROL_ACTION_SUBSCRIBE; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_NUMBER; - -@Service -public class NumberStatisticsRoutingParticipant extends RoutingParticipant { - - private final NumberStatisticsService numberStatisticsService; - - public NumberStatisticsRoutingParticipant(final NumberStatisticsService numberStatisticsService, - @Value("${number-generator.subscribe-uri}") String subscribeUri, - @Value("${number-generator.routing-channel}") String routingChannel, - @Value("${number-generator.predicate}") String predicate, - @Value("${number-generator.expression-language}") String expressionLanguage, - @Value("${number-generator.subscription-priority}") int subscriptionPriority, - @Value("${number-generator.consume-uri}") String consumeUri, - @Value("${number-generator.command-uri}") String commandUri, - ProducerTemplate producerTemplate, - CamelContext camelContext) { - super("processNumberStats", subscribeUri, routingChannel, subscriptionPriority, - predicate, expressionLanguage, consumeUri, commandUri, producerTemplate, camelContext); - this.numberStatisticsService = numberStatisticsService; - } - - /** - * Send the subscribe message after this service instance is created. - */ - @Override - protected void subscribe() { - DynamicRouterControlMessage message = createSubscribeMessage(); - producerTemplate.sendBody(COMPONENT_SCHEME_CONTROL + ":" + CONTROL_ACTION_SUBSCRIBE, message); - } - - /** - * This method consumes messages that have matched the participant's rules - * and have been routed to the participant. It adds the results to the - * results service. - * - * @param body the serialized command message - */ - @Override - @Consume(property = "consumeUri") - public void consumeMessage(final String body, @Header(value = HEADER_NUMBER) String number) { - this.numberStatisticsService.updateStats(body); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/NumberGeneratorService.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/NumberGeneratorService.java deleted file mode 100644 index 2ea265d..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/NumberGeneratorService.java +++ /dev/null
@@ -1,70 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.service; - -import jakarta.validation.constraints.NotNull; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.mainrouter.model.StateMachineEvent; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; - -import java.util.Map; - -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.COMMAND_PROCESS_NUMBER; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.ENDPOINT_DIRECT_COMMAND; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_COMMAND; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_NUMBER; -import static org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events.GENERATE_NUMBERS_COMPLETE; - -@Service -public class NumberGeneratorService { - - private static final Logger LOG = LoggerFactory.getLogger(NumberGeneratorService.class); - - private final ProducerTemplate producerTemplate; - - private final ApplicationEventPublisher eventPublisher; - - public NumberGeneratorService(@NotNull final ProducerTemplate producerTemplate, - ApplicationEventPublisher eventPublisher) { - this.producerTemplate = producerTemplate; - this.eventPublisher = eventPublisher; - producerTemplate.start(); - } - - /** - * When a command has been received to generate numbers, this will continuously generate - * numbers and send them in a command to have recipients process the numbers. It will - * only stop when a limit (if any) is reached, or if a subsequent command instructs - * number message generation to stop - * - * @param limit the count of numbers to produce (zero means Integer.MAX_VALUE) - */ - public void generateNumbers(int limit) { - String msg; - try { - LOG.info("Generating numbers from 1 to {}", limit); - Flux.range(1, limit) - .flatMap(n -> Mono.just(n) - .map(Object::toString) - .subscribeOn(Schedulers.boundedElastic()) - .doOnNext(strN -> producerTemplate.sendBodyAndHeaders(ENDPOINT_DIRECT_COMMAND, strN, - Map.of(HEADER_COMMAND, COMMAND_PROCESS_NUMBER, HEADER_NUMBER, strN)))) - .doFinally(x -> { - Message<MainRouterUtil.Events> message = - MessageBuilder.withPayload(GENERATE_NUMBERS_COMPLETE).build(); - eventPublisher.publishEvent(new StateMachineEvent(this, message)); - }) - .subscribe(); - } catch (Exception e) { - msg = String.format("Exception when trying to send number messages: %s", e.getMessage()); - LOG.warn(msg, e); - } - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/NumberStatisticsService.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/NumberStatisticsService.java deleted file mode 100644 index 03c6aa0..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/NumberStatisticsService.java +++ /dev/null
@@ -1,66 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.service; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.common.model.CommandMessage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import java.util.Map; -import java.util.concurrent.ConcurrentSkipListMap; -import java.util.concurrent.atomic.AtomicLong; - -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.COMMAND_RESET_STATS; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.ENDPOINT_DIRECT_COMMAND; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_COMMAND; - -@Service -public class NumberStatisticsService { - - private static final Logger LOG = LoggerFactory.getLogger(NumberStatisticsService.class); - - private final Map<String, Long> countsMap; - - private final AtomicLong currentMs = new AtomicLong(0L); - - private long start = 0L; - - private final ProducerTemplate producerTemplate; - - private final ObjectMapper objectMapper; - - public NumberStatisticsService(final ProducerTemplate producerTemplate, - final ObjectMapper objectMapper) { - this.producerTemplate = producerTemplate; - this.countsMap = new ConcurrentSkipListMap<>(); - this.objectMapper = objectMapper; - } - - public String resetStats() { - start = System.currentTimeMillis(); - countsMap.clear(); - currentMs.set(0L); - producerTemplate.sendBodyAndHeader(ENDPOINT_DIRECT_COMMAND, COMMAND_RESET_STATS, HEADER_COMMAND, COMMAND_RESET_STATS); - return "OK - Statistics have been reset."; - } - - public void updateStats(final String body) { - try { - CommandMessage message = objectMapper.readValue(body, CommandMessage.class); - long now = System.currentTimeMillis(); - long newTime = now - start; - long elapsed = currentMs.updateAndGet(cv -> Math.max(cv, newTime)); - countsMap.put("elapsed seconds", elapsed / 1000); - message.params().forEach((key, val) -> countsMap.merge(key, Long.parseLong(val), Math::max)); - } catch (JsonProcessingException e) { - LOG.warn("Error when trying to update number statistics", e); - } - } - - public Map<String, Long> getCounts() { - LOG.info("Getting number statistics"); - return Map.copyOf(countsMap); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/StateMachineEventTriggerService.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/StateMachineEventTriggerService.java deleted file mode 100644 index f596da8..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/StateMachineEventTriggerService.java +++ /dev/null
@@ -1,27 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.service; - -import org.apache.camel.example.springboot.numbers.mainrouter.model.StateMachineEvent; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.event.EventListener; -import org.springframework.statemachine.StateMachine; -import org.springframework.stereotype.Service; - -@Service -public class StateMachineEventTriggerService { - - private static final Logger LOG = LoggerFactory.getLogger(StateMachineEventTriggerService.class); - - private final StateMachine<MainRouterUtil.States, MainRouterUtil.Events> stateMachine; - - public StateMachineEventTriggerService(StateMachine<MainRouterUtil.States, MainRouterUtil.Events> stateMachine) { - this.stateMachine = stateMachine; - } - - @EventListener - public void onEvent(StateMachineEvent event) { - LOG.info("Received state machine event: {}", event.getMessage().getPayload().name()); - MainRouterUtil.sendEventAndMapResponse.apply(stateMachine, event.getMessage()).subscribe(); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/SubscribersService.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/SubscribersService.java deleted file mode 100644 index 1d7d9f8..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/SubscribersService.java +++ /dev/null
@@ -1,25 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.service; - -import org.apache.camel.ProducerTemplate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -@Service -public class SubscribersService { - - private static final Logger LOG = LoggerFactory.getLogger(SubscribersService.class); - - private final ProducerTemplate producerTemplate; - - public SubscribersService(final ProducerTemplate producerTemplate) { - this.producerTemplate = producerTemplate; - producerTemplate.start(); - } - - public String listSubscriptions(final String channel) { - LOG.info("Getting subscriptions list for channel '{}'", channel); - return producerTemplate.requestBodyAndHeader( - "direct:list", "", "subscribeChannel", channel, String.class); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/WarmUpService.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/WarmUpService.java deleted file mode 100644 index 99bb717..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/service/WarmUpService.java +++ /dev/null
@@ -1,63 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.service; - -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.mainrouter.model.StateMachineEvent; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.stereotype.Service; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.core.scheduler.Schedulers; - -import java.util.Map; - -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.COMMAND_PROCESS_NUMBER; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.ENDPOINT_DIRECT_COMMAND; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_COMMAND; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_NUMBER; -import static org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events.INITIALIZATION_COMPLETE; - -/** - * This service sends a small number of messages through the system shortly after startup to - * warm up the JVM so that we can see optimal results the first time we run a batch of - * messages through the system. - */ -@Service -public class WarmUpService { - - private static final Logger LOG = LoggerFactory.getLogger(WarmUpService.class); - - private final ProducerTemplate producerTemplate; - - private final ApplicationEventPublisher eventPublisher; - - public WarmUpService(ProducerTemplate producerTemplate, - ApplicationEventPublisher eventPublisher) { - this.producerTemplate = producerTemplate; - this.eventPublisher = eventPublisher; - } - - /** - * Sends messages for the warm-up. - */ - public void doWarmUp() { - LOG.info("Running warm-up..."); - Flux.range(1, 1000000) - .flatMap(n -> Mono.just(n) - .subscribeOn(Schedulers.boundedElastic()) - .map(String::valueOf) - .doOnNext(ns -> producerTemplate.sendBodyAndHeaders(ENDPOINT_DIRECT_COMMAND, 1, - Map.of(HEADER_COMMAND, COMMAND_PROCESS_NUMBER, - HEADER_NUMBER, ns)))) - .doFinally(x -> { - LOG.info("Warm-up finished"); - Message<Events> message = MessageBuilder.withPayload(INITIALIZATION_COMPLETE).build(); - eventPublisher.publishEvent(new StateMachineEvent(this, message)); - }) - .subscribe(); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/util/MainRouterUtil.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/util/MainRouterUtil.java deleted file mode 100644 index 5ac2b61..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/util/MainRouterUtil.java +++ /dev/null
@@ -1,50 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.util; - -import org.springframework.messaging.Message; -import org.springframework.statemachine.StateMachine; -import reactor.core.publisher.Mono; - -import java.util.function.BiFunction; - -public class MainRouterUtil { - - public static final BiFunction<StateMachine<States, Events>, Message<Events>, Mono<String>> sendEventAndMapResponse = (sm, m) -> - sm.sendEvent(Mono.just(m)) - .next() - .map(er -> - switch (er.getResultType()) { - case ACCEPTED -> "Event accepted."; - case DENIED -> "Event denied."; - case DEFERRED -> "Event deferred."; - }); - - public enum States { - STARTING("Starting"), - INITIALIZING("Initializing"), - READY("Ready"), - GENERATING_NUMBERS("Generating Numbers"); - - private final String description; - - States(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - } - - public enum Events { - PARTICIPANT_SUBSCRIBED("Routing Participant Subscribed"), - INITIALIZATION_COMPLETE("Initialization Complete"), - GENERATE_NUMBERS_STARTED("Generate Numbers Started"), - GENERATE_NUMBERS_COMPLETE("Generate Numbers Complete"); - - private final String description; - - Events(String description) { - this.description = description; - } - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/NumberGeneratorController.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/NumberGeneratorController.java deleted file mode 100644 index 0e57754..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/NumberGeneratorController.java +++ /dev/null
@@ -1,33 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.web; - -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events; -import org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.States; -import org.springframework.messaging.Message; -import org.springframework.messaging.support.MessageBuilder; -import org.springframework.statemachine.StateMachine; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_EVENT_LIMIT; -import static org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.Events.GENERATE_NUMBERS_STARTED; -import static org.apache.camel.example.springboot.numbers.mainrouter.util.MainRouterUtil.sendEventAndMapResponse; - -@RestController -public class NumberGeneratorController { - - final StateMachine<States, Events> stateMachine; - - public NumberGeneratorController(StateMachine<States, Events> stateMachine) { - this.stateMachine = stateMachine; - } - - @PutMapping(path = "/generate") - public Mono<String> generate(@RequestParam("limit") int limit) { - Message<Events> message = MessageBuilder.withPayload(GENERATE_NUMBERS_STARTED) - .setHeader(HEADER_EVENT_LIMIT, limit) - .build(); - return sendEventAndMapResponse.apply(stateMachine, message); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/NumberStatisticsController.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/NumberStatisticsController.java deleted file mode 100644 index b50559a..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/NumberStatisticsController.java +++ /dev/null
@@ -1,40 +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 org.apache.camel.example.springboot.numbers.mainrouter.web; - -import org.apache.camel.example.springboot.numbers.mainrouter.service.NumberStatisticsService; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -import java.util.Map; - -@RestController -public class NumberStatisticsController { - - private final NumberStatisticsService numberStatisticsService; - - public NumberStatisticsController(NumberStatisticsService numberStatisticsService) { - this.numberStatisticsService = numberStatisticsService; - } - - @GetMapping(path = "/counts") - public Mono<Map<String, Long>> getCounts() { - return Mono.just(numberStatisticsService.getCounts()); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/SubscribersController.java b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/SubscribersController.java deleted file mode 100644 index 8e5ef6f..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/java/org/apache/camel/example/springboot/numbers/mainrouter/web/SubscribersController.java +++ /dev/null
@@ -1,22 +0,0 @@ -package org.apache.camel.example.springboot.numbers.mainrouter.web; - -import org.apache.camel.example.springboot.numbers.mainrouter.service.SubscribersService; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; -import reactor.core.publisher.Mono; - -@RestController -public class SubscribersController { - - private final SubscribersService subscribersService; - - public SubscribersController(SubscribersService subscribersService) { - this.subscribersService = subscribersService; - } - - @GetMapping(path = "/list/{channel}") - public Mono<String> listSubscriptions(@PathVariable("channel") String channel) { - return Mono.just(subscribersService.listSubscriptions(channel)); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/resources/application.yaml b/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/resources/application.yaml deleted file mode 100644 index fea4351..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/main-router/src/main/resources/application.yaml +++ /dev/null
@@ -1,45 +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. -# -app: - name: "main-router" - port: 8082 - id: "main_router" - predicate: "{headers.command == 'stats'}" - priority: 10 -camel: - springboot: - name: CamelSpringBootDynamicRouterExampleMainRouter - jmx-enabled: false - shutdown-timeout: 30 - endpoint-bridge-error-handler: true - component: - dynamic-router: - enabled: true - lazy-start-producer: true - spring-event: - bridge-error-handler: true - kafka: - bridge-error-handler: true -main-router: - dynamic-router-component: - routing-channel: "numbers" - recipient-mode: "allMatch" -logging: - level: - root: WARN - org.apache.kafka: ERROR - org.apache.camel: INFO
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/pom.xml b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/pom.xml deleted file mode 100644 index 5be4da0..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/pom.xml +++ /dev/null
@@ -1,45 +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. - --> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://maven.apache.org/POM/4.0.0" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-dynamic-router-eip-stack</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>numbers-common</artifactId> - <packaging>jar</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples :: Multimodule :: Common Library</name> - - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <configuration> - <skip>true</skip> - </configuration> - </plugin> - </plugins> - </build> -</project> \ No newline at end of file
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/config/CommonConfig.java b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/config/CommonConfig.java deleted file mode 100644 index c7a9a8b..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/config/CommonConfig.java +++ /dev/null
@@ -1,37 +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 org.apache.camel.example.springboot.numbers.common.config; - -import org.apache.camel.component.kafka.serde.KafkaHeaderDeserializer; -import org.apache.camel.example.springboot.numbers.common.service.StringValueHeaderDeserializer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.scheduling.annotation.EnableScheduling; - -@EnableScheduling -@Configuration -@PropertySource(value = "classpath:application.yaml", factory = YamlPropertySourceFactory.class, ignoreResourceNotFound = true) -@PropertySource(value = "classpath:common.yaml", factory = YamlPropertySourceFactory.class, ignoreResourceNotFound = true) -public class CommonConfig { - - @Bean - KafkaHeaderDeserializer stringValueHeaderDeserializer() { - return new StringValueHeaderDeserializer(); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/config/YamlPropertySourceFactory.java b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/config/YamlPropertySourceFactory.java deleted file mode 100644 index d0f260e..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/config/YamlPropertySourceFactory.java +++ /dev/null
@@ -1,28 +0,0 @@ -package org.apache.camel.example.springboot.numbers.common.config; - -import org.springframework.core.io.Resource; -import org.springframework.lang.NonNull; -import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; -import org.springframework.core.env.PropertiesPropertySource; -import org.springframework.core.env.PropertySource; -import org.springframework.core.io.support.EncodedResource; -import org.springframework.core.io.support.PropertySourceFactory; - -import java.util.Optional; -import java.util.Properties; - -public class YamlPropertySourceFactory implements PropertySourceFactory { - - @Override - @NonNull - public PropertySource<?> createPropertySource(String name, EncodedResource encodedResource) { - YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); - Resource resource = encodedResource.getResource(); - String resourceFileName = Optional.ofNullable(resource.getFilename()) - .orElseThrow(() -> new IllegalArgumentException("Resource file name must not be null")); - factory.setResources(resource); - Properties properties = Optional.ofNullable(factory.getObject()) - .orElseThrow(() -> new IllegalArgumentException("Properties factory object must not be null")); - return new PropertiesPropertySource(resourceFileName, properties); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/model/CommandMessage.java b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/model/CommandMessage.java deleted file mode 100644 index f6cfb31..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/model/CommandMessage.java +++ /dev/null
@@ -1,34 +0,0 @@ -package org.apache.camel.example.springboot.numbers.common.model; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -public record CommandMessage(String command, Map<String, String> params) { - - @JsonIgnore - private static final AtomicInteger errorCount = new AtomicInteger(0); - - @JsonIgnore - private static final ObjectMapper objectMapper = new ObjectMapper(new JsonFactory()); - - @Override - public String toString() { - String result; - try { - result = objectMapper.writeValueAsString(this); - } catch (Exception ex) { - result = Map.of("errorCount", String.valueOf(errorCount.incrementAndGet()), - "errorMessage", ex.getMessage()).entrySet().stream() - .map(e -> String.format(""" - "%s":"%s" - """, e.getKey(), e.getValue())) - .collect(Collectors.joining(",", "{", "}")); - } - return result; - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/ProcessNumbersRoutingParticipant.java b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/ProcessNumbersRoutingParticipant.java deleted file mode 100644 index 0005442..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/ProcessNumbersRoutingParticipant.java +++ /dev/null
@@ -1,94 +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 org.apache.camel.example.springboot.numbers.common.service; - -import org.apache.camel.CamelContext; -import org.apache.camel.Consume; -import org.apache.camel.Header; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.common.model.CommandMessage; -import org.springframework.scheduling.annotation.Scheduled; - -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.COMMAND_RESET_STATS; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.COMMAND_STATS; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_COMMAND; -import static org.apache.camel.example.springboot.numbers.common.util.NumbersCommonUtil.HEADER_NUMBER; - -public abstract class ProcessNumbersRoutingParticipant extends RoutingParticipant { - - protected final String numberName; - - /** - * Counter for the number of messages that this participant has processed. - */ - protected final AtomicInteger processedCount = new AtomicInteger(0); - - /** - * The count that was last reported via "stats" command message. - */ - protected final AtomicInteger reportedCount = new AtomicInteger(0); - - protected ProcessNumbersRoutingParticipant( // NOSONAR - String numberName, - String subscriberId, - String subscribeUri, - String routingChannel, - int subscriptionPriority, - String predicate, - String expressionLanguage, - String consumeUri, - String commandUri, - ProducerTemplate producerTemplate, - CamelContext camelContext) { - super(subscriberId, subscribeUri, routingChannel, subscriptionPriority, predicate, expressionLanguage, - consumeUri, commandUri, producerTemplate, camelContext); - this.numberName = numberName; - producerTemplate.start(); - } - - /** - * This method consumes messages that have matched the participant's rules - * and have been routed to the participant. - * - * @param body the serialized command message - */ - @Override - @Consume(property = "consumeUri") - public void consumeMessage(final String body, @Header(value = HEADER_NUMBER) String number) { - if (COMMAND_RESET_STATS.equals(body)) { - processedCount.set(0); - reportedCount.set(0); - } else { - processedCount.incrementAndGet(); - } - } - - @Scheduled(fixedRate = 2, timeUnit = TimeUnit.SECONDS) - public void sendStats() { - int pCount = processedCount.get(); - if (pCount > reportedCount.get()) { - CommandMessage command = new CommandMessage(COMMAND_STATS, Map.of(numberName, String.valueOf(pCount))); - producerTemplate.sendBodyAndHeader(commandUri, command.toString(), HEADER_COMMAND, COMMAND_STATS); - reportedCount.set(pCount); - } - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/RoutingParticipant.java b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/RoutingParticipant.java deleted file mode 100644 index 1226311..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/RoutingParticipant.java +++ /dev/null
@@ -1,166 +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 org.apache.camel.example.springboot.numbers.common.service; - -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.Header; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.dynamicrouter.control.DynamicRouterControlMessage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.event.EventListener; - -public abstract class RoutingParticipant { - - protected static final Logger LOG = LoggerFactory.getLogger(RoutingParticipant.class); - - private final ObjectMapper objectMapper = new ObjectMapper(new JsonFactory()); - - protected final String subscriberId; - - /** - * The dynamic router control channel URI where subscribe messages will - * be sent. - */ - protected final String subscribeUri; - - /** - * The channel of the dynamic router to send messages. - */ - protected final String routingChannel; - - /** - * The priority of the processor when evaluated by the dynamic router. Lower - * number means higher priority. - */ - protected final int priority; - - /** - * The predicate by which exchanges are evaluated for suitability for - * a routing participant. - */ - protected final String predicate; - - /** - * The language of the predicate string. - */ - protected final String expressionLanguage; - - /** - * The URI that a participant implementation will listen on for messages - * that match its rules. - */ - protected final String consumeUri; - - /** - * URI to send a command to (for dynamic routing). - */ - protected final String commandUri; - - /** - * The {@link ProducerTemplate} to send subscriber messages to the dynamic - * router control channel. - */ - protected final ProducerTemplate producerTemplate; - - protected final CamelContext camelContext; - - protected RoutingParticipant( // NOSONAR - String subscriberId, - String subscribeUri, - String routingChannel, - int subscriptionPriority, - String predicate, - String expressionLanguage, - String consumeUri, - String commandUri, - ProducerTemplate producerTemplate, - CamelContext camelContext) { - this.subscriberId = subscriberId; - this.subscribeUri = subscribeUri; - this.routingChannel = routingChannel; - this.priority = subscriptionPriority; - this.predicate = predicate; - this.expressionLanguage = expressionLanguage; - this.consumeUri = consumeUri; - this.commandUri = commandUri; - this.producerTemplate = producerTemplate; - this.camelContext = camelContext; - producerTemplate.start(); - } - - /** - * Send the subscribe message after this service instance is created. - */ - protected void subscribe() { - try { - DynamicRouterControlMessage message = createSubscribeMessage(); - String messageJson = objectMapper.writeValueAsString(message); - LOG.info("Sending subscribe message: {} to {}", messageJson, subscribeUri); - producerTemplate.sendBody(subscribeUri, messageJson); - } catch (Exception e) { - throw new IllegalStateException("Could not serialize a message", e); - } - } - - /** - * After the application is started and ready, subscribe for messages. - */ - @EventListener(ApplicationReadyEvent.class) - protected void start() { - subscribe(); - } - - /** - * This method consumes messages that have matched the participant's rules - * and have been routed to the participant. It adds the results to the - * results service. - * - * @param body the serialized command message - */ - public abstract void consumeMessage(final String body, @Header(value = "number") String number); - - /** - * Create a {@link DynamicRouterControlMessage} based on parameters from the - * implementing class. - * - * @return the {@link DynamicRouterControlMessage} - */ - protected DynamicRouterControlMessage createSubscribeMessage() { - return DynamicRouterControlMessage.Builder.newBuilder() - .subscribeChannel(routingChannel) - .subscriptionId(subscriberId) - .destinationUri(consumeUri) - .priority(priority) - .predicate("#" + predicate) - .expressionLanguage(expressionLanguage) - .build(); - } - - /** - * Gets the consumer URI. - * - * @return the consumer URI - */ - public String getConsumeUri() { - return this.consumeUri; - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/StringValueHeaderDeserializer.java b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/StringValueHeaderDeserializer.java deleted file mode 100644 index 2d0f825..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/service/StringValueHeaderDeserializer.java +++ /dev/null
@@ -1,30 +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 org.apache.camel.example.springboot.numbers.common.service; - -import org.apache.camel.component.kafka.serde.KafkaHeaderDeserializer; - -import java.nio.charset.StandardCharsets; - -public class StringValueHeaderDeserializer implements KafkaHeaderDeserializer { - - @Override - public Object deserialize(String key, byte[] value) { - return new String(value, StandardCharsets.UTF_8); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/util/NumbersCommonUtil.java b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/util/NumbersCommonUtil.java deleted file mode 100644 index 0dbcfbd..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/java/org/apache/camel/example/springboot/numbers/common/util/NumbersCommonUtil.java +++ /dev/null
@@ -1,25 +0,0 @@ -package org.apache.camel.example.springboot.numbers.common.util; - -/** - * Common constants and methods. - */ -public abstract class NumbersCommonUtil { - - private NumbersCommonUtil() {} - - public static final String ENDPOINT_DIRECT_COMMAND = "direct:command"; - - public static final String ENDPOINT_DIRECT_LIST = "direct:list"; - - public static final String COMMAND_PROCESS_NUMBER = "processNumber"; - - public static final String COMMAND_RESET_STATS = "resetStats"; - - public static final String COMMAND_STATS = "stats"; - - public static final String HEADER_COMMAND = "command"; - - public static final String HEADER_EVENT_LIMIT = "limit"; - - public static final String HEADER_NUMBER = "number"; -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/resources/common.yaml b/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/resources/common.yaml deleted file mode 100644 index e09004a..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/numbers-common/src/main/resources/common.yaml +++ /dev/null
@@ -1,54 +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. -# -spring: - application: - name: "${app.name}" - webflux: - base-path: "/${app.name}" -server: - port: ${app.port} -management: - endpoints: - enabled-by-default: false - web: - exposure: - include: "health" - endpoint: - health: - enabled: true -camel: - component: - kafka: - brokers: "broker:9092" - partitioner: "org.apache.kafka.clients.producer.RoundRobinPartitioner" - groupId: "numbers" - bridge-error-handler: true - jmx: - disabled: true -number-generator: - routing-channel: "numbers" - subscribe-uri: "kafka://control?groupInstanceId=${app.id}_subscribe&headerDeserializer=#stringValueHeaderDeserializer&partitioner=org.apache.kafka.clients.producer.RoundRobinPartitioner" - command-uri: "kafka://numbers_command?groupInstanceId=${app.id}_command&headerDeserializer=#stringValueHeaderDeserializer&partitioner=org.apache.kafka.clients.producer.RoundRobinPartitioner" - consume-uri: "kafka://${app.id}?groupInstanceId=${app.id}_consumer&headerDeserializer=#stringValueHeaderDeserializer" - predicate: "${app.predicate}" - expression-language: "spel" - subscription-priority: ${app.priority} -logging: - level: - root: WARN - org.apache.kafka: ERROR - org.apache.camel: INFO
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/pom.xml b/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/pom.xml deleted file mode 100644 index c6cbbfa..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/pom.xml +++ /dev/null
@@ -1,41 +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. - --> -<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://maven.apache.org/POM/4.0.0" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-dynamic-router-eip-stack</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>odd-numbers-service</artifactId> - <packaging>jar</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples :: Multimodule :: Odd Numbers Service</name> - - <dependencies> - <dependency> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>numbers-common</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - -</project> \ No newline at end of file
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/odd/Application.java b/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/odd/Application.java deleted file mode 100644 index 40c8120..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/odd/Application.java +++ /dev/null
@@ -1,31 +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 org.apache.camel.example.springboot.numbers.odd; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication(scanBasePackages = "org.apache.camel.example.springboot.numbers") -public class Application { - - /** - * Main method to start the application. Please make us proud. - */ - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/odd/service/ProcessOddNumbersRoutingParticipant.java b/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/odd/service/ProcessOddNumbersRoutingParticipant.java deleted file mode 100644 index 415406c..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/java/org/apache/camel/example/springboot/numbers/odd/service/ProcessOddNumbersRoutingParticipant.java +++ /dev/null
@@ -1,42 +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 org.apache.camel.example.springboot.numbers.odd.service; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.example.springboot.numbers.common.service.ProcessNumbersRoutingParticipant; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -@Service -public class ProcessOddNumbersRoutingParticipant extends ProcessNumbersRoutingParticipant { - - public ProcessOddNumbersRoutingParticipant( - @Value("${number-generator.subscribe-uri}") String subscribeUri, - @Value("${number-generator.routing-channel}") String routingChannel, - @Value("${number-generator.predicate}") String predicate, - @Value("${number-generator.expression-language}") String expressionLanguage, - @Value("${number-generator.subscription-priority}") int subscriptionPriority, - @Value("${number-generator.consume-uri}") String consumeUri, - @Value("${number-generator.command-uri}") String commandUri, - ProducerTemplate producerTemplate, - CamelContext camelContext) { - super("odd", "processOddNumbers", subscribeUri, routingChannel, subscriptionPriority, - predicate, expressionLanguage, consumeUri, commandUri, producerTemplate, camelContext); - } -}
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/resources/application.yaml b/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/resources/application.yaml deleted file mode 100644 index 84a25e9..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/odd-numbers-service/src/main/resources/application.yaml +++ /dev/null
@@ -1,22 +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. -# -app: - name: "odd-numbers" - port: 8901 - id: "numbers_odd" - predicate: "{(headers.command == 'processNumber' and headers.number matches '\\d*[13579]') or headers.command == 'resetStats'}" - priority: 10
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/pom.xml b/dynamic-router-eip/dynamic-router-eip-stack/pom.xml deleted file mode 100644 index d72d302..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/pom.xml +++ /dev/null
@@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>camel-example-spring-boot-dynamic-router-eip</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-example-spring-boot-dynamic-router-eip-stack</artifactId> - <packaging>pom</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples :: Multimodule</name> - <description>Dynamic Router EIP component example in Spring Boot with multiple modules</description> - - <modules> - <module>numbers-common</module> - <module>main-router</module> - <module>all-numbers-service</module> - <module>even-numbers-service</module> - <module>odd-numbers-service</module> - </modules> - - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-actuator</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-kafka-starter</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.statemachine</groupId> - <artifactId>spring-statemachine-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-jackson-starter</artifactId> - </dependency> - </dependencies> -</project>
diff --git a/dynamic-router-eip/dynamic-router-eip-stack/project-resources/docker/compose.yaml b/dynamic-router-eip/dynamic-router-eip-stack/project-resources/docker/compose.yaml deleted file mode 100644 index 854eaf6..0000000 --- a/dynamic-router-eip/dynamic-router-eip-stack/project-resources/docker/compose.yaml +++ /dev/null
@@ -1,140 +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. -# - -services: - redpanda_broker: - image: docker.io/vectorized/redpanda:v23.2.19 - container_name: broker - networks: - - test-dynamic-router - volumes: - - broker:/var/lib/redpanda/data:rw - user: "101:101" - cap_add: - - SYS_NICE - privileged: true - command: - - redpanda start - - --overprovisioned - - --smp 1 - - --memory 1G - - --reserve-memory 0M - - --kafka-addr internal://broker:9092 - - --advertise-kafka-addr internal://broker:9092 - - --pandaproxy-addr internal://broker:8082 - - --advertise-pandaproxy-addr internal://broker:8082 - - --schema-registry-addr internal://0.0.0.0:8081 - - --rpc-addr broker:33145 - - --advertise-rpc-addr broker:33145 - - --mode dev-container - - --default-log-level=warn - healthcheck: - test: ["CMD-SHELL", "rpk cluster health | grep -E 'Healthy:.+true' || exit 1"] - interval: 30s - timeout: 10s - retries: 5 - start_period: 10s - - main_router_service: - image: docker.io/library/main-router:latest - container_name: main_router_service - ports: - - "8082:8082" - networks: - - test-dynamic-router - environment: - - THC_PATH=/main-router/actuator/health - - THC_PORT=8082 - healthcheck: - test: [ "CMD", "/workspace/health-check" ] - interval: 30s - timeout: 10s - retries: 5 - start_period: 10s - depends_on: - redpanda_broker: - condition: service_healthy - - all_numbers_service: - image: docker.io/library/all-numbers-service:latest - container_name: all_numbers_service - ports: - - "8911:8911" - networks: - - test-dynamic-router - environment: - - THC_PATH=/all-numbers/actuator/health - - THC_PORT=8911 - healthcheck: - test: [ "CMD", "/workspace/health-check" ] - interval: 30s - timeout: 10s - retries: 5 - start_period: 10s - depends_on: - main_router_service: - condition: service_healthy - - even_numbers_service: - image: docker.io/library/even-numbers-service:latest - container_name: even_numbers_service - ports: - - "8902:8902" - networks: - - test-dynamic-router - environment: - - THC_PATH=/even-numbers/actuator/health - - THC_PORT=8902 - healthcheck: - test: [ "CMD", "/workspace/health-check" ] - interval: 30s - timeout: 10s - retries: 5 - start_period: 10s - depends_on: - main_router_service: - condition: service_healthy - - odd_numbers_service: - image: docker.io/library/odd-numbers-service:latest - container_name: odd_numbers_service - ports: - - "8901:8901" - networks: - - test-dynamic-router - environment: - - THC_PATH=/odd-numbers/actuator/health - - THC_PORT=8901 - healthcheck: - test: [ "CMD", "/workspace/health-check" ] - interval: 30s - timeout: 10s - retries: 5 - start_period: 10s - depends_on: - main_router_service: - condition: service_healthy - -networks: - test-dynamic-router: - driver: bridge - ipam: - config: - - subnet: 10.5.0.0/16 - -volumes: - broker: null \ No newline at end of file
diff --git a/dynamic-router-eip/pom.xml b/dynamic-router-eip/pom.xml deleted file mode 100644 index e2a381e..0000000 --- a/dynamic-router-eip/pom.xml +++ /dev/null
@@ -1,184 +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. - ---> -<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"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.camel.springboot.example</groupId> - <artifactId>examples</artifactId> - <version>4.13.0-SNAPSHOT</version> - </parent> - - <artifactId>camel-example-spring-boot-dynamic-router-eip</artifactId> - <packaging>pom</packaging> - - <name>Camel SB Examples :: Dynamic Router EIP :: Examples</name> - <description>Dynamic Router EIP component examples</description> - - <modules> - <module>dynamic-router-eip-single</module> - <module>dynamic-router-eip-stack</module> - </modules> - - <properties> - <category>EIP</category> - <spring-statemachine.version>4.0.0</spring-statemachine.version> - </properties> - - <!-- Spring-Boot and Camel BOM --> - <dependencyManagement> - <dependencies> - <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> - <dependency> - <groupId>org.springframework.statemachine</groupId> - <artifactId>spring-statemachine-bom</artifactId> - <version>${spring-statemachine.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-webflux</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-spring-starter</artifactId> - </dependency> - <dependency> - <groupId>org.apache.camel.springboot</groupId> - <artifactId>camel-dynamic-router-starter</artifactId> - </dependency> - </dependencies> - - <build> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>${spring-boot-version}</version> - <configuration combine.children="append"> - <image> - <name>docker.io/library/${project.artifactId}</name> - <env> - <BPE_DELIM_JAVA_TOOL_OPTIONS xml:space="preserve"> </BPE_DELIM_JAVA_TOOL_OPTIONS> - <BPE_APPEND_JAVA_TOOL_OPTIONS>--add-opens=java.base/sun.net=ALL-UNNAMED</BPE_APPEND_JAVA_TOOL_OPTIONS> - <BP_HEALTH_CHECKER_ENABLED>true</BP_HEALTH_CHECKER_ENABLED> - <THC_PATH>/actuator/health</THC_PATH> - </env> - <buildpacks> - <buildpack>urn:cnb:builder:paketo-buildpacks/java</buildpack> - <buildpack>gcr.io/paketo-buildpacks/health-checker:latest</buildpack> - </buildpacks> - </image> - <layers> - <enabled>true</enabled> - </layers> - <jvmArguments>--add-opens=java.base/sun.net=ALL-UNNAMED</jvmArguments> - </configuration> - </plugin> - </plugins> - </pluginManagement> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <executions> - <execution> - <id>process-aot</id> - <goals> - <goal>process-aot</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - <profiles> - <profile> - <id>podman</id> - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <docker> - <host>${XDG_RUNTIME_DIR}/podman/podman.sock</host> - <bindHostToBuilder>true</bindHostToBuilder> - </docker> - </configuration> - <executions> - <execution> - <goals> - <goal>build-image-no-fork</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>docker</id> - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <docker> - <host>/var/run/docker.sock</host> - <bindHostToBuilder>true</bindHostToBuilder> - </docker> - </configuration> - <executions> - <execution> - <goals> - <goal>build-image-no-fork</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> -</project> \ No newline at end of file
diff --git a/pom.xml b/pom.xml index 22d2b86..74333ba 100644 --- a/pom.xml +++ b/pom.xml
@@ -44,7 +44,6 @@ <module>artemis</module> <module>aws-secrets-manager</module> <module>aws2-s3</module> - <module>dynamic-router-eip</module> <module>endpointdsl</module> <module>fhir</module> <module>fhir-auth-tx</module>