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
The following commit(s) were added to refs/heads/main by this push:
new 70b84e134b7a CAMEL-16861: Update docs
70b84e134b7a is described below
commit 70b84e134b7aaaaca7190f81377c38992719a592
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Feb 24 16:21:32 2026 +0100
CAMEL-16861: Update docs
---
docs/user-manual/modules/ROOT/pages/routes.adoc | 69 +++++++++++++++++++++----
1 file changed, 59 insertions(+), 10 deletions(-)
diff --git a/docs/user-manual/modules/ROOT/pages/routes.adoc
b/docs/user-manual/modules/ROOT/pages/routes.adoc
index 0e834eed4490..13fdc400842b 100644
--- a/docs/user-manual/modules/ROOT/pages/routes.adoc
+++ b/docs/user-manual/modules/ROOT/pages/routes.adoc
@@ -5,17 +5,24 @@ In Apache Camel, a _route_ is a set of processing steps that
are applied to a me
A Camel _route_ is where the integration flow is defined. For example, you can
write a Camel route to specify how two systems can be integrated. You can also
specify how the data can be manipulated, routed, or mediated between the
systems.
The routes are typically defined using a simple, declarative syntax that is
easy to read and understand.
+Camel supports _coding_ routes in different xref:dsl.adoc[DSLs] of your choice.
-For instance, you could write a _route_ to consume files from an FTP server
and send them to an http://activemq.apache.org[ActiveMQ] messaging system. A
_route_ to do so, using xref:java-dsl.adoc[Java DSL], would look like this:
+For instance, you could write a _route_ to consume files from an FTP server
and send them to an http://activemq.apache.org[ActiveMQ] messaging system.
+A _route_ to do so, would look like this:
+[tabs]
+====
+
+Java::
++
[source,java]
----
from("ftp:myserver/folder")
.to("activemq:queue:cheese");
----
-Camel _routes_ can be defined using a variety of xref:dsl.adoc[domain-specific
languages (DSLs)], such as Java, Spring XML, or YAML. For example, you could
write the _route_ described above using XML:
-
+XML::
++
[source,xml]
----
<route>
@@ -24,6 +31,20 @@ Camel _routes_ can be defined using a variety of
xref:dsl.adoc[domain-specific l
</route>
----
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: ftp:myserver/folder
+ steps:
+ - to:
+ uri: activemq:queue:cheese
+----
+====
+
+
== Route Description and Notes
You can add a description to your routes, for example to provide a short human
summary of what the route does.
@@ -104,6 +125,7 @@ YAML::
TIP: You can also add description and notes to EIP patterns
+
== Writing Routes in Java using the Java DSL
You can create a route using the Java language by extending the
xref:manual::route-builder.adoc[`RouteBuilder` class], and implementing the
`configure` method.
@@ -111,13 +133,30 @@ You can create a route using the Java language by
extending the xref:manual::rou
Here's an example:
[source,java]
-------------------------------------------------------
+----
RouteBuilder builder = new RouteBuilder() {
public void configure() {
from("direct:a").to("direct:b");
}
};
-------------------------------------------------------
+----
+
+The code above is an anonymous class, and its more common to create your own
class when using Java DSL for example we
+can create a class called `MyRoute` which then implements the route as follows:
+
+[source,java]
+----
+import org.apache.camel.builder.RouteBuilder;
+
+public class MyRoute extends RouteBuilder {
+
+ @Override
+ public void configure() {
+ from("direct:a").to("direct:b");
+ }
+
+}
+----
As you can see from the code snippet above, Camel uses
xref:manual::uris.adoc[URIs] to wire endpoints together.
@@ -125,10 +164,19 @@ We refer to this way of writing route as using the
xref:manual::java-dsl.adoc[Ja
== Route Precondition
-The routes can be included or not according to the result of a test. You can
express the condition for the tests using the simple language. Camel evaluates
this condition only once during the initialization phase.
+The routes can be included or not according to the result of a test. You can
express the condition for the tests using the simple language.
+Camel evaluates this condition only once during the initialization phase.
+
+NOTE: When a route is not included due to precondition, then the route is
skipped by Camel, and its not possible to include the router later during
runtime.
+If you want to include the route, but not start the route, then you can set
`autoStartup=false` on the route. Which allows to start the route later during
runtime.
Here's an example that includes the route only if the parameter `format` has
been set to `xml`:
+[tabs]
+====
+
+Java::
++
[source,java]
----
from("direct:in").precondition("'{{format}}' == 'xml'")
@@ -136,8 +184,8 @@ from("direct:in").precondition("'{{format}}' == 'xml'")
.to("direct:out");
----
-You can write the same route described above using the
xref:components:others:java-xml-io-dsl.adoc[XML DSL]:
-
+XML::
++
[source,xml]
----
<route precondition="'{{format}}' == 'xml'">
@@ -147,8 +195,8 @@ You can write the same route described above using the
xref:components:others:ja
</route>
----
-You can also write the same route described above using the
xref:components:others:yaml-dsl.adoc[YAML DSL]:
-
+YAML::
++
[source,yaml]
----
- route:
@@ -160,6 +208,7 @@ You can also write the same route described above using the
xref:components:othe
jaxb: {}
- to: "direct:out"
----
+====
== More Information