You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "Steve973 (via GitHub)" <gi...@apache.org> on 2023/12/17 21:50:27 UTC

[PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Steve973 opened a new pull request, #12467:
URL: https://github.com/apache/camel/pull/12467

   # Description
   Reworked the Dynamic Router EIP Component to fix URI subscribing, and to make the component simpler by using the recipient list processor, and having the component focus on managing subscriptions instead of reinventing wheels.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (note that Camel 3 uses `camel-3.x`, whereas Camel 4 uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it).
   
   - [x] I checked that each commit in the pull request has a meaningful subject line and body.
   
   - [x] I have run `mvn clean install -DskipTests` locally and I have committed all auto-generated changes
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #12467:
URL: https://github.com/apache/camel/pull/12467#issuecomment-1859294772

   :star2: Thank you for your contribution to the Apache Camel project! :star2: 
   
   :robot: CI automation will test this PR automatically.
   
   :camel: Apache Camel Committers, please review the following items:
   
   * First-time contributors **require MANUAL approval** for the GitHub Actions to run
   
   * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot.
   
   * You can label PRs using `build-all`, `build-dependents`, `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
   
   * Build and test logs are available in the Summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary. 
   
   * :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1430939957


##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"

Review Comment:
   No just remove <camelContext> and only show generic <route> then it works anywhere with XML



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1434501945


##########
components/camel-dynamic-router/pom.xml:
##########
@@ -40,8 +41,24 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core-processor</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>jakarta.validation</groupId>
+      <artifactId>jakarta.validation-api</artifactId>
+      <version>3.0.2</version>

Review Comment:
   I got rid of the dependencies that had hard coded version so these are gone, too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1430584273


##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"

Review Comment:
   I got rid of the spring bean XML code snippets.  They were redundant in the fact that they just showed an alternative way to set things up.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on PR #12467:
URL: https://github.com/apache/camel/pull/12467#issuecomment-1867108254

   @davsclaus the previous build failed because I didn't re-generate the sources after the version got bumped to 4.4.0-SNAPSHOT.  I think it should be good now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1430581892


##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+		http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+    <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:subscribe"/>
+            <toD uri="dynamic-router-control:subscribe

Review Comment:
   Did you see the whole URI?
   ```
               <toD uri="dynamic-router-control:subscribe
                         ?subscribeChannel=myChannel
                         &amp;subscriptionId=mySubId
                         &amp;destinationUri=direct:myDestination
                         &amp;priority=5
                         &amp;predicate=true
                         &amp;expressionLanguage=simple"/>
   ```
   That's definitely dynamic, so I need it there for the documentation to be correct.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on PR #12467:
URL: https://github.com/apache/camel/pull/12467#issuecomment-1867634731

   @davsclaus 
   
   Thank you for taking the time to look at this, even if it was too much to examine thoroughly enough.  I would welcome a more thorough review when you have the time for this, if possible.  I enjoy contributing to Camel, and I want to make sure that I am contributing in a way that is most helpful for Camel and the committers.  Please let me know if there is some way that we can go through this so that I can learn the Camel way of doing this a bit better.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1430584273


##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"

Review Comment:
   I will make sure to convert all of the examples that use spring xml to something else (perhaps Spring Java config).  I can also do that for the integration tests that use old spring xml.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1430576367


##########
components/camel-dynamic-router/pom.xml:
##########
@@ -40,8 +41,24 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core-processor</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>jakarta.validation</groupId>
+      <artifactId>jakarta.validation-api</artifactId>
+      <version>3.0.2</version>

Review Comment:
   I probably do not need the validation annotation that I was using, so I'll remove it.  For the future, do you prefer the use of a property for the version, or something else?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1433331773


##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"

Review Comment:
   It's removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1434501533


##########
components/camel-dynamic-router/pom.xml:
##########
@@ -40,8 +41,24 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core-processor</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>jakarta.validation</groupId>
+      <artifactId>jakarta.validation-api</artifactId>
+      <version>3.0.2</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>2.16.0</version>

Review Comment:
   It's gone.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1430576839


##########
components/camel-dynamic-router/pom.xml:
##########
@@ -40,8 +41,24 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core-processor</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>jakarta.validation</groupId>
+      <artifactId>jakarta.validation-api</artifactId>
+      <version>3.0.2</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>2.16.0</version>

Review Comment:
   I like using a jackson object mapper to get a string representation of an object, but I see how that is not really necessary, so I'll get rid of it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1429776133


##########
components/camel-dynamic-router/pom.xml:
##########
@@ -40,8 +41,24 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core-processor</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>jakarta.validation</groupId>
+      <artifactId>jakarta.validation-api</artifactId>
+      <version>3.0.2</version>

Review Comment:
   Do not use hardcoded versions



##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+		http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+    <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:subscribe"/>
+            <toD uri="dynamic-router-control:subscribe

Review Comment:
   There seems to not be any dynamic in this, so it can maybe be a static to



##########
components/camel-dynamic-router/pom.xml:
##########
@@ -40,8 +41,24 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core-processor</artifactId>
     </dependency>
-
+    <dependency>
+      <groupId>jakarta.validation</groupId>
+      <artifactId>jakarta.validation-api</artifactId>
+      <version>3.0.2</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>2.16.0</version>

Review Comment:
   Do not use hardcoded versions
   And why is jackson needed ?



##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"

Review Comment:
   We are not recommending old Spring <beans> today. Can you just make the example with Camel <route>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "Steve973 (via GitHub)" <gi...@apache.org>.
Steve973 commented on code in PR #12467:
URL: https://github.com/apache/camel/pull/12467#discussion_r1434503361


##########
components/camel-dynamic-router/src/main/docs/dynamic-router-control-component.adoc:
##########
@@ -0,0 +1,247 @@
+= Dynamic Router Control Component
+:doctitle: Dynamic Router Control
+:shortname: dynamic-router-control
+:artifactid: camel-dynamic-router
+:description: The Dynamic Router control endpoint for operations that allow routing participants to subscribe or unsubscribe to participate in dynamic message routing.
+:since: 4.3
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+//Manually maintained attributes
+:camel-spring-boot-name: dynamic-router-control
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The Dynamic Router Control endpoint is a special type of endpoint in the Dynamic Router component where routing
+participants can subscribe or unsubscribe dynamically at runtime. By sending control messages to this endpoint,
+participants can specify their own routing rules and alter the dynamic rule base of the Dynamic Router component in
+real-time. Participants can choose between using URI query parameters, and sending a control message as the exchange
+message body.
+
+== URI format
+
+[source]
+----
+dynamic-router-control:controlAction[?options]
+----
+
+// component-configure options: START
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+=== Subscribing
+
+Subscribing can be achieved by using query parameters in the control endpoint URI, or by sending a
+`DynamicRouterControlMessage` to the control endpoint URI.
+
+===== URI examples
+
+.Example Java URI `RouteBuilder` Subscription
+[source,java]
+----
+// Send a subscribe request to the dynamic router that will match every exchange and route messages to the URI: "direct:myDestination"
+from("direct:subscribe").to("dynamic-router-control:subscribe?subscribeChannel=myChannel&subscriptionId=mySubId&destinationUri=direct:myDestination&priority=5&predicate=true&expressionLanguage=simple");
+----
+
+.Example Java URI `ProducerTemplate` Subscription
+[source,java]
+----
+CamelContext context = new DefaultCamelContext();
+context.start();
+ProducerTemplate template = context.createProducerTemplate();
+RouteBuilder.addRoutes(context, rb -> {
+    // Route for subscriber destination
+    rb.from("direct:myDestination")
+            .to("log:dynamicRouterExample?showAll=true&multiline=true");
+    // Route for subscribing
+    rb.from("direct://subscribe")
+            .toD("dynamic-router-control://subscribe" +
+                    "?subscribeChannel=${header.subscribeChannel}" +
+                    "&subscriptionId=${header.subscriptionId}" +
+                    "&destinationUri=${header.destinationUri}" +
+                    "&priority=${header.priority}" +
+                    "&predicateBean=${header.predicateBean}");
+});
+Predicate predicate = PredicateBuilder.constant(true);
+context.getRegistry().bind("predicate", predicate);
+template.sendBodyAndHeaders("direct:subscribe", "",
+        Map.of("subscribeChannel", "test",
+                "subscriptionId", "testSubscription1",
+                "destinationUri", "direct:myDestination",
+                "priority", "1",
+                "predicateBean", "predicate"));
+----
+Above, because the control URI is dynamic, and since a `ProducerTemplate` does not have a built-in way to send to a
+dynamic URI, we have to send subscription parameters from a `ProducerTemplate` in a different way.  The dynamic-aware
+endpoint uses headers "under the hood", because the URI params are converted to headers, so we can set the headers
+deliberately.
+
+.Example XML URI Subscription
+[source,xml]
+----
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+		http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+		http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd ">
+
+    <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:subscribe"/>
+            <toD uri="dynamic-router-control:subscribe

Review Comment:
   The dynamic aware part takes a look at the query parameters and removes them while adding them to headers and the query parameters that you see here are the ones that it uses when it's converting to the plain endpoint without query parameters.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-20247: Rework of dynamic router EIP component. [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus merged PR #12467:
URL: https://github.com/apache/camel/pull/12467


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org