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-unsubscr...@camel.apache.org

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

Reply via email to