Skip to content

Commit 74e855c

Browse files
CAMEL-25068: camel-core - Docs: a RouteTemplateContext reused for several routes shares the template beans of the first route
Review of apache#27466: the template beans bound for the first route are kept in the RouteTemplateContext and are then seen as beans of the caller, so the later routes share them. Say so in route-template.adoc and the 4.23 upgrade guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cf61015 commit 74e855c

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ The `org.apache.camel.processor.InterceptSendToEndpointCallback` class is deprec
503503
- A bean bound by `TemplatedRouteBuilder.bean` or in a `templatedRoute` is now used instead of a `templateBean` with
504504
the same name, which is no longer created. Prior to Camel 4.23 the template bean replaced it when both had the same
505505
type, and was used when the route looked the bean up by the type of the template bean (such as `process("myBean")`).
506+
When the same `RouteTemplateContext` is reused for several `addRouteFromTemplate` calls, the template beans bound for
507+
the first route are now kept as beans of the caller, so the later routes share these instances instead of each
508+
getting new ones. Use a new `RouteTemplateContext` per route to get new template beans for each route.
506509

507510
=== camel-aws2-ddb
508511

‎docs/user-manual/modules/ROOT/pages/route-template.adoc‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ See xref:route-template-bean-binding.adoc[Route Template Bean Binding] for detai
654654

655655
A bean that is bound when creating the route (`TemplatedRouteBuilder.bean` or the beans of a `templatedRoute`)
656656
takes precedence over a `templateBean` with the same name, which is then not created. This allows replacing a
657-
template bean, for example with a mock in a test.
657+
template bean, for example with a mock in a test. The template beans are bound to the `RouteTemplateContext` too, so
658+
when the same `RouteTemplateContext` is reused for several `addRouteFromTemplate` calls, the routes after the first
659+
share the template beans created for the first route; use a new `RouteTemplateContext` per route to get new ones.
658660

659661
== Configuring route templates when creating route (advanced)
660662

0 commit comments

Comments
 (0)