Skip to content

Commit 4b0cd2e

Browse files
committed
CAMEL-16861: Update docs
1 parent a1ec66d commit 4b0cd2e

3 files changed

Lines changed: 146 additions & 68 deletions

File tree

docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Google recommends migrating your Pub/Sub Lite workloads to either:
110110

111111
* **Google Cloud Pub/Sub** → use the `camel-google-pubsub` component
112112
* **Google Cloud Managed Service for Apache Kafka** → use the `camel-kafka` component
113+
113114
=== camel-mail
114115

115116
When configured a custom `IdempotentRepository` on `camel-mail` endpoint, then Camel will now auto-start

docs/user-manual/modules/ROOT/pages/route-policy.adoc

Lines changed: 133 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ kind of use cases.
99

1010
You associate a route with a given `RoutePolicy` and then during
1111
runtime Camel will invoke callbacks on this policy where you can
12-
implement your custom logic. Camel provides a support class that is a
13-
good base class to extend `org.apache.camel.support.RoutePolicySupport`.
12+
implement your custom logic. Camel provides a support class that can be used
13+
to extend `org.apache.camel.support.RoutePolicySupport` and implement your logic.
1414

1515
There are these callbacks invoked:
1616

@@ -40,12 +40,17 @@ fast.
4040
based policy modeled after the circuit breaker. This policy will stop consuming
4141
from an endpoint based on the type of exceptions that are thrown and the threshold setting.
4242

43+
* `org.apache.camel.impl.cluster.ClusteredRoutePolicy` - is the foundation for `camel-cluster`
44+
which handles Camel routes to become active if a node becomes leader in a cluster.
45+
4346
Camel also provides an ability to schedule routes to
4447
be activated, deactivated, suspended and/or resumed at certain times
4548
during the day using a
4649
xref:scheduledroutepolicy.adoc[ScheduledRoutePolicy] (offered via the
4750
xref:components::quartz-component.adoc[Quartz] component).
4851

52+
And route policy is also used as an implementation details for some of the Camel observability components.
53+
4954
== SuspendableService
5055

5156
If you want to dynamic suspend/resume routes, then it is advised to
@@ -63,22 +68,11 @@ The throttling in flight route policy has the following options:
6368

6469
[width="100%",cols="10%,10%,80%",options="header",]
6570
|===
66-
6771
|Option |Default |Description
68-
69-
|`scope` |`Route` |A scope for either `Route` or `Context` which defines if the current
70-
number of in flight exchanges is context based or for that particular
71-
route.
72-
73-
|`maxInflightExchanges` |`1000` |The maximum threshold when the throttling will start to suspend the
74-
route if the current number of in flight exchanges is higher than this
75-
value.
76-
77-
|`resumePercentOfMax` |`70` |A percentage `0..100` which defines when the throttling should resume
78-
again in case it has been suspended.
79-
72+
|`scope` |`Route` |A scope for either `Route` or `Context` which defines if the current number of in flight exchanges is context based or for that particular route.
73+
|`maxInflightExchanges` |`1000` |The maximum threshold when the throttling will start to suspend the route if the current number of in flight exchanges is higher than this value.
74+
|`resumePercentOfMax` |`70` |A percentage `0..100` which defines when the throttling should resume again in case it has been suspended.
8075
|`loggingLevel` |`INFO` |The logging level used for logging the throttling activity.
81-
8276
|`logger` |`ThrottlingInflightRoutePolicy` |The logger category.
8377
|===
8478

@@ -101,84 +95,171 @@ messages per time unit.
10195

10296
See xref:scheduledroutepolicy.adoc[Scheduled Route Policy] for scheduling based route policy.
10397

104-
== Using route policies in Camel routes
98+
== Using RoutePolicy in Camel routes
99+
100+
On the route(s) that should use one or more route policies, you configure this as shown below:
105101

106-
You configure the route policy as follows from Java DSL, using the
107-
`routePolicy` method:
102+
[tabs]
103+
====
108104
105+
Java::
106+
+
107+
You configure the route policy as follows from Java DSL, using the `routePolicy` method:
108+
+
109109
[source,java]
110-
-----------------------------------------------------------
110+
----
111111
RoutePolicy myPolicy = new MyRoutePolicy();
112112
113-
from("seda:foo").routePolicy(myPolicy).to("mock:result");
114-
-----------------------------------------------------------
115-
116-
In Spring XML you configure using the `routePolictRef` attribute on `<route>` as shown:
113+
from("seda:foo")
114+
.routePolicy(myPolicy)
115+
.to("mock:result");
116+
----
117117
118+
XML::
119+
+
120+
In XML you configure using the `routePolictRef` attribute on `<route>` as shown:
121+
+
118122
[source,xml]
119-
---------------------------------------------------------
123+
----
120124
<bean id="myPolicy" class="com.mycompany.MyRoutePolicy"/>
121125
122126
<route routePolicyRef="myPolicy">
123127
<from uri="seda:foo"/>
124128
<to uri="mock:result"/>
125129
</route>
126-
---------------------------------------------------------
130+
----
131+
132+
YAML::
133+
+
134+
In YAML you configure using the `routePolictRef` attribute on `route` node as shown:
135+
+
136+
[source,yaml]
137+
----
138+
- route:
139+
routePolicyRef: myPolicy
140+
from:
141+
uri: seda:foo
142+
steps:
143+
- to:
144+
uri: mock:result
145+
----
146+
====
127147

128148
You can configure one or more route policies (separated by comma), such as:
129149

150+
[tabs]
151+
====
152+
153+
Java::
154+
+
130155
[source,java]
131156
----
132-
from("seda:foo").routePolicy(myPolicy, myOtherPolicy).to("mock:result");
157+
from("seda:foo")
158+
.routePolicy(myPolicy, myOtherPolicy)
159+
.to("mock:result");
133160
----
134161
135-
And in XML:
136-
162+
XML::
163+
+
137164
[source,xml]
138-
---------------------------------------------------------
165+
----
166+
<bean id="myPolicy" class="com.mycompany.MyRoutePolicy"/>
167+
139168
<route routePolicyRef="myPolicy,myOtherPolicy">
140169
<from uri="seda:foo"/>
141170
<to uri="mock:result"/>
142171
</route>
143-
---------------------------------------------------------
172+
----
173+
174+
YAML::
175+
+
176+
[source,yaml]
177+
----
178+
- route:
179+
routePolicyRef: myPolicy,myOtherPolicy
180+
from:
181+
uri: seda:foo
182+
steps:
183+
- to:
184+
uri: mock:result
185+
----
186+
====
187+
144188

145189
== Using RoutePolicyFactory
146190

147191
If you want to use a route policy for every route, you can use
148-
a `org.apache.camel.spi.RoutePolicyFactory` as a factory for creating
149-
a `RoutePolicy` instance for each route. This can be used when you
150-
want to use the same kind of route policy for all or some routes.
192+
a `org.apache.camel.spi.RoutePolicyFactory` as a factory for creating new
193+
`RoutePolicy` instance(s) for each route. This can be used when you
194+
want to use the same kind of route policy for all.
151195

152196
With the factory, you only need to configure this once, and every route created will
153197
have the policy assigned.
154198

155199
There is API on `CamelContext` to add a factory, as shown below
156200

201+
[tabs]
202+
====
203+
204+
Java::
205+
+
157206
[source,java]
158-
----------------------------------------------------------
207+
----
208+
CamelContext context = ...
159209
context.addRoutePolicyFactory(new MyRoutePolicyFactory());
160-
----------------------------------------------------------
161-
162-
And from XML DSL you just define a `<bean>` with the factory, and Camel will automatically detect this factory:
210+
----
163211
164-
[source,xml]
165-
----------------------------------------------------------------------
166-
<bean id="myRoutePolicyFactory" class="com.foo.MyRoutePolicyFactory"/>
167-
----------------------------------------------------------------------
212+
Spring Boot::
213+
+
214+
You can also mark your class with Spring Boot `@Component` for automatic dependency injection
215+
+
216+
[source,java]
217+
----
218+
@Component
219+
public class MyRoutePolicyFactory() {
168220
169-
You can have as many route policy factories as you want, so if you have two factories,
170-
you can add them both as shown:
221+
}
222+
----
171223
224+
Quarkus::
225+
+
226+
You can also mark your class with Quarkus `@.ApplicationScoped` for automatic dependency injection
227+
+
172228
[source,java]
173-
----------------------------------------------------------
174-
context.addRoutePolicyFactory(new MyRoutePolicyFactory());
175-
context.addRoutePolicyFactory(new MyOtherRoutePolicyFactory());
176-
----------------------------------------------------------
229+
----
230+
@ApplicationScoped
231+
public class MyRoutePolicyFactory() {
177232
178-
And in XML:
233+
}
234+
----
179235
236+
237+
Spring XML::
238+
+
239+
And from Spring XML DSL you just define a `<bean>` with the factory, and Camel will automatically detect this factory:
240+
+
180241
[source,xml]
181-
----------------------------------------------------------------------
242+
----
182243
<bean id="myRoutePolicyFactory" class="com.foo.MyRoutePolicyFactory"/>
183-
<bean id="myOtherRoutePolicyFactory" class="com.foo.MyOtherRoutePolicyFactory"/>
184-
----------------------------------------------------------------------
244+
----
245+
246+
XML::
247+
+
248+
[source,xml]
249+
----
250+
<bean name="myRoutePolicyFactory" type="com.foo.MyRoutePolicyFactory"/>
251+
----
252+
253+
YAML::
254+
+
255+
[source,yaml]
256+
----
257+
- beans:
258+
- name: myRoutePolicyFactory
259+
type: com.foo.MyRoutePolicyFactory
260+
----
261+
====
262+
263+
TIP: You can have as many route policy factories as you want, so if you have two factories,
264+
you can just add both of them.
265+

docs/user-manual/modules/ROOT/pages/route-reload.adoc

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ for file changes in the file system (i.e., using `file` and not `classpath`).
1616

1717
The route reloading can be configured in Java or with Spring Boot, Quarkus in the following way:
1818

19+
[tabs]
20+
====
21+
22+
Java::
23+
+
1924
[source,java]
2025
----
2126
CamelContext context = ...
@@ -27,8 +32,10 @@ reload.setPattern("*.xml");
2732
context.addService(reload);
2833
----
2934
30-
And with Camel Quarkus / Camel Main you can configure this in `application.properties:`
31-
35+
Application Properties::
36+
+
37+
And with Spring Boot, Quarkus, Standalone you can configure this in `application.properties:`
38+
+
3239
[source,properties]
3340
----
3441
# turn on route reloading on file changes
@@ -38,18 +45,7 @@ camel.main.routes-reload-directory = myfolder/routes
3845
# pattern(s) for files to watch
3946
camel.main.routes-reload-pattern = *.xml
4047
----
41-
42-
And in Spring Boot:
43-
44-
[source,properties]
45-
----
46-
# turn on route reloading on file changes
47-
camel.springboot.routes-reload-enabled = true
48-
# the base directory to watch
49-
camel.springboot.routes-reload-directory = myfolder/routes
50-
# pattern(s) for files to watch
51-
camel.springboot.routes-reload-pattern = *.xml
52-
----
48+
====
5349

5450
=== Route Reload Options
5551

@@ -80,5 +76,5 @@ See related xref:context-reload.adoc[].
8076

8177
See the following examples that come with live reloading enabled:
8278

83-
- https://github.com/apache/camel-examples/tree/main/main-xml[camel-examples/examples/main-xml]
84-
- https://github.com/apache/camel-examples/tree/main/main-yaml[camel-examples/examples/main-yaml]
79+
- https://github.com/apache/camel-examples/tree/main/main-xml[Standalone XML DSL]
80+
- https://github.com/apache/camel-examples/tree/main/main-yaml[Standalone YAML DSL]

0 commit comments

Comments
 (0)