Claus Ibsen created CAMEL-27261:
-----------------------------------
Summary: camel-kamelet - Kamelet EIPs with the same name and
options share one callback, so a message runs the nested steps of another route
Key: CAMEL-27261
URL: https://issues.apache.org/jira/browse/CAMEL-27261
Project: Camel
Issue Type: Bug
Components: camel-kamelet
Reporter: Claus Ibsen
A Kamelet EIP ({{kamelet}} with nested steps) registers its nested steps with
{{KameletComponent.addKameletEip(key, processor)}} when it is initialized,
under the key {{templateId/routeId}} of its producer. {{KameletProducer}} for
{{kamelet:sink}} looks that key up to continue. Two uses of the same Kamelet
with the same options resolve to the same endpoint, so the same Kamelet route
and the same key:
* *Two Kamelet EIPs with the same name and options, in different routes:* the
last registration wins. The messages of the first route run the nested steps of
the second, and its own nested steps never run.
* *A {{to("kamelet:X?opts")}} and a Kamelet EIP with the same name and
options:* the messages of the {{to}} route also run the nested steps of the
EIP, on their own thread, before they continue.
It affects every action Kamelet, as Camel adds {{kamelet:sink}} to the end of
an action template. Reproduced with {{camel run}} on 4.10.0, 4.23.0 and
4.24.0-SNAPSHOT, with the Kamelet catalog's {{insert-header-action}}:
{code:yaml}
- route:
id: routeB1
from:
uri: "timer:b1?repeatCount=1&delay=2000"
steps:
- setBody:
constant: 'from-B1'
- kamelet:
name: "insert-header-action?name=foo&value=bar"
steps:
- log: "B1 nested step got: ${body}"
- route:
id: routeB2
from:
uri: "timer:b2?repeatCount=1&delay=4000"
steps:
- setBody:
constant: 'from-B2'
- kamelet:
name: "insert-header-action?name=foo&value=bar"
steps:
- log: "B2 nested step got: ${body}"
{code}
logs {{B2 nested step got: from-B1}} and {{B2 nested step got: from-B2}}; the
B1 step never runs.
Expected: each Kamelet EIP continues with its own nested steps, and a
{{to("kamelet:...")}} is not affected by an EIP. For example, each Kamelet EIP
gets its own Kamelet route, with a routeId unique to that EIP, so its callback
key is unique.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)