oscerd commented on issue #2771:
URL: 
https://github.com/apache/camel-kamelets/issues/2771#issuecomment-5496422471

   `{{counter}}` is the correct syntax, and the shipped Kamelet works 
unmodified on the exact version you reported. I think the problem is in how it 
is being instantiated rather than in the Kamelet.
   
   ## Reproduction on Camel 4.18.0
   
   ```yaml
   - route:
       id: cnt-probe
       from:
         uri: "kamelet:counter-source"
         parameters:
           period: 500
           start: 7
           numbers: 3
         steps:
         - log:
             message: "COUNTER body=[${body}] type=[${body.class.simpleName}]"
   ```
   
   ```
   Apache Camel 4.18.0 (cnt-probe) is starting
   COUNTER body=[7] type=[Integer]
   COUNTER body=[8] type=[Integer]
   ```
   
   Counting from the configured `start`, incrementing, bean resolving. Same 
result on 4.21, so nothing changed in between that would explain it.
   
   ## Why the three syntaxes behave the way they do
   
   The `beans:` block in a Kamelet is a **route template** bean, not a registry 
bean. When the template is instantiated, Camel registers that bean under a 
*generated* unique name (so two Kamelet instances get independent counters) and 
exposes the generated name as a local property. That is what `{{counter}}` 
resolves to.
   
   That explains all three of your results:
   
   - `ref: "{{counter}}"` — correct, but the local property only exists when 
the YAML is instantiated **as a route template**, via `kamelet:counter-source`. 
Loading the file as a plain route, or copying its `template:` block into a 
route of your own, leaves `{{counter}}` with nothing to resolve against, giving 
exactly your `Property with key [counter] not found`.
   - `ref: "counter"` and `bean:counter?method=getAndIncrement` — these look 
for a registry bean literally named `counter`, which never exists, because the 
instantiated name is generated. Hence `No bean could be found in the registry 
for: counter`.
   
   So the message you saw is consistent with the Kamelet being loaded as a 
route rather than routed to through the `kamelet:` component.
   
   ## What to check in your application
   
   You mentioned a programmatic `SimpleRegistry`. Two things worth confirming:
   
   1. The Kamelet YAML is discovered as a **Kamelet** (on the classpath under 
`/kamelets`, or via `camel.component.kamelet.location`) and you reach it with 
`from("kamelet:counter-source?start=7")` — rather than adding the YAML file as 
a route definition.
   2. `camel-kamelet` is on the classpath alongside `camel-bean`. Without it 
the `kamelet:` component is not there and it is easy to fall back to loading 
the file directly.
   
   Leaving this open rather than closing it, since I cannot see your bootstrap 
code. If your setup does route through `kamelet:` and it still fails, could you 
post the snippet that loads and starts the context? That would tell us quickly 
whether there is a genuine gap in the route-template bean mechanism — which 
would be a fix in `apache/camel` rather than in this catalog.
   
   ---
   _Claude Code on behalf of Andrea Cosentino_
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to