You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/11/01 18:20:46 UTC

[camel] 01/02: CAMEL-16861: Cleanup docs

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 22b0d0ea1ab073058789cbf4b26d90d38fac362f
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Nov 1 19:06:45 2021 +0100

    CAMEL-16861: Cleanup docs
---
 ...ing-route-startup-ordering-and-autostartup.adoc | 135 ++++++++++++---------
 1 file changed, 75 insertions(+), 60 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/configuring-route-startup-ordering-and-autostartup.adoc b/docs/user-manual/modules/ROOT/pages/configuring-route-startup-ordering-and-autostartup.adoc
index 20b0688..592daac 100644
--- a/docs/user-manual/modules/ROOT/pages/configuring-route-startup-ordering-and-autostartup.adoc
+++ b/docs/user-manual/modules/ROOT/pages/configuring-route-startup-ordering-and-autostartup.adoc
@@ -15,36 +15,40 @@ The auto startup can be configured on two levels:
 - CamelContext - _Globally_
 - Route - _Individually per route_
 
-For example the CamelContext below we have configured `autoStartup=false` to
-prevent Camel starting all the routes when Spring starts.
+For example the xref:camelcontext.adoc[CamelContext] below we have configured `autoStartup=false` to
+prevent Camel starting all the routes on startup.
 
 [source,xml]
 ----
-    <camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring" autoStartup="false">
-        <route>
-            <from uri="direct:foo"/>
-            <to uri="mock:foo"/>
-        </route>
-        <route>
-            <from uri="direct:bar"/>
-            <to uri="mock:bar"/>
-        </route>
-    </camelContext>
+<camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring"
+              autoStartup="false">
+    <route>
+        <from uri="direct:foo"/>
+        <to uri="mock:foo"/>
+    </route>
+    <route>
+        <from uri="direct:bar"/>
+        <to uri="mock:bar"/>
+    </route>
+</camelContext>
 ----
 
 So how do you start the routes?
 
 The `autoStartup` option on the `<camelContext>` is only used once, so you
 can manually start Camel later by invoking its `start` method in Java as shown
-below:
+below.
+
+For example when using Spring, you can get hold of the `CamelContext` via
+the Spring `ApplicationContext`:
 
 [source,java]
 ----
-    ApplicationContext ac = ...
-    CamelContext camel = (CamelContext) ac.getBean("myCamel");
+ApplicationContext ac = ...
+CamelContext camel = (CamelContext) ac.getBean("myCamel");
 
-    // now start all the routes
-    camel.getRouteController().startAllRoutes();
+// now start all the routes
+camel.getRouteController().startAllRoutes();
 ----
 
 TIP: The routes can also be started via JMX (requires `camel-management` JAR to be on the classpath) by invoking the `startAllRoutes` operation on the CamelContext MBean.
@@ -52,11 +56,9 @@ TIP: The routes can also be started via JMX (requires `camel-management` JAR to
 === Autostartup per route level
 
 You can also use the `autoStartup` option to configure if a given route
-should be started when Camel starts. By default a route is auto started.
-
-You can disable or enable it as follows.
+should be started when Camel starts. By default, a route is auto started.
 
-In XML DSL you define it as follows:
+In XML DSL you disable auto startup as follows:
 
 [source,xml]
 ----
@@ -76,20 +78,19 @@ And to explicit state it should be started:
 </route>
 ----
 
-=== Autostartup in Java DSL
-
-Configuring auto startup on `CamelContext` is done as follows:
+And in Java DSL you can configure auto startup on `CamelContext` as follows:
 
 [source,java]
 ----
 camelCopntext.setAutoStartup(false);
 ----
 
-And on route level you can disable (is enabled by default):
+And on route level you can disable it via `noAutoStartup`:
 
 [source,java]
 ----
-from("activemq:queue:special").noAutoStartup().to("file://backup");
+from("activemq:queue:special").noAutoStartup()
+    .to("file://backup");
 ----
 
 To startup based on a boolean, String or
@@ -97,27 +98,31 @@ xref:components::properties-component.adoc[Property], do one of the following:
 
 [source,java]
 ----
-boolean startupRoute = true;
-from("activemq:queue:special").autoStartup(startupRoute).to("file://backup");
+// using a boolean
+from("activemq:queue:special").autoStartup(false)
+    .to("file://backup");
 
-String startupRoute = "true";
-from("activemq:queue:special").autoStartup(startupRoute).to("file://backup");
+// using a string
+from("activemq:queue:special").autoStartup("false")
+    .to("file://backup");
 
-from("activemq:queue:special").autoStartup("{{startupRouteProperty}}").to("file://backup");
+// using property placeholders
+from("activemq:queue:special").autoStartup("{{startupRouteProperty}}")
+    .to("file://backup");
 ----
 
 == Configuring starting order for routes
 
 You can also configure the order in which routes are started. Previously
-Camel started the routes in a non deterministic order. Now you have fine
-grained control in which order the routes should be started. There is a
+Camel started the routes in a non-deterministic order. Now you have
+fine-grained control in which order the routes should be started. There is a
 new attribute `startupOrder` which is an `Integer` that states the order.
 Camel then sorts the routes before starting time. The routes with the
 lowest `startupOrder` are started first and the ones with the highest are
 started last.
 
 IMPORTANT: All `startupOrder` defined must be unique among all routes in your
-xref:camelcontext.adoc[CamelContext]. Otherwise if there are clashes in
+xref:camelcontext.adoc[CamelContext]. Otherwise, if there are clashes in
 `startupOrder` numbers among routes, the routes will fail to start up throwing
 `org.apache.camel.FailedToStartRouteException`.
 
@@ -149,14 +154,18 @@ Let's try a couple of examples.
 
 [source,java]
 ----
-    from("seda:foo").startupOrder(1).to("mock:result");
-    from("direct:start").startupOrder(2).to("seda:foo");
+from("seda:foo").startupOrder(1)
+    .to("mock:result");
+
+from("direct:start").startupOrder(2)
+    .to("seda:foo");
 ----
 
 And the same example with XML DSL:
 
 [source,xml]
 ----
+<routes>
     <route startupOrder="1">
         <from uri="seda:foo"/>
         <to uri="mock:result"/>
@@ -166,30 +175,36 @@ And the same example with XML DSL:
         <from uri="direct:start"/>
         <to uri="seda:foo"/>
     </route>
+</routes>
 ----
 
 In this example we have two routes in which we have started that the
-`direct:start` route should be started *after* the `seda:foo` route.
-As `direct:start` is consider the input and we want that `seda:foo`
+direct:start route should be started *after* the seda:foo route.
+Because direct:start is considered the input, and we want seda:foo
 route to be up and running beforehand.
 
-You can also mix and match routes with and without `startupOrder`
-define.
+=== Using startOrder together with non startOrder
 
-=== Startup ordering example with startupOrder and without
+You can also mix and match routes with and without `startupOrder` defined.
+The first two routes below have start order defined, and the last route has not.
 
 [source,java]
 ----
-    from("seda:foo").startupOrder(1).to("mock:result");
-    from("direct:start").startupOrder(2).to("seda:foo");
+from("seda:foo").startupOrder(1)
+    .to("mock:result");
+
+from("direct:start").startupOrder(2)
+    .to("seda:foo");
 
-    from("direct:bar").to("seda:bar");
+from("direct:bar")
+    .to("seda:bar");
 ----
 
 And the same example with XML DSL:
 
 [source,xml]
 ----
+<routes>
     <route startupOrder="1">
         <from uri="seda:foo"/>
         <to uri="mock:result"/>
@@ -204,10 +219,11 @@ And the same example with XML DSL:
         <from uri="direct:bar"/>
         <to uri="seda:bar"/>
     </route>
+</routes>
 ----
 
 In the route above we have *not* defined a `startupOrder` on the last
-route `direct:bar` in which Camel will auto assign a number for it, in
+route direct:bar in which Camel will auto assign a number for it, in
 which this case will be 1000; therefore the route will be started
 last.
 
@@ -220,30 +236,29 @@ You can use a high number in `startupOrder` to have a specific route startup las
 
 [source,java]
 ----
-    // use auto assigned startup ordering
-    from("direct:start").to("seda:foo");
+// use auto assigned startup ordering
+from("direct:start").to("seda:foo");
 
-    // should start first
-    from("seda:foo").startupOrder(1).to("mock:result");
+// should start first
+from("seda:foo").startupOrder(1).to("mock:result");
 
-    // should start last after the default routes
-    from("direct:bar").startupOrder(12345).to("seda:bar");
+// should start last after the default routes
+from("direct:bar").startupOrder(12345).to("seda:bar");
 
-    // use auto assigned startup ordering
-    from("seda:bar").to("mock:other");
+// use auto assigned startup ordering
+from("seda:bar").to("mock:other");
 ----
 
 In the example above the order of startups of routes should be:
 
-1. `seda://foo`
-2. `direct://start`
-3. `seda://bar`
-4. `direct://bar`
+1. seda:foo
+2. direct:start
+3. seda:bar
+4. direct:bar
 
 === Shutting down routes
 
-Camel will shutdown the routes in the *reverse* order that
-they were started.
+Camel will shut down the routes in the *reverse* order that they were started.
 
-See also xref:graceful-shutdown.adoc[Graceful Shutdown].
+See more at xref:graceful-shutdown.adoc[Graceful Shutdown].