shashank created CAMEL-26338:
--------------------------------
Summary: camel-core - a hook for every processing step, that can
delay or fail the step
Key: CAMEL-26338
URL: https://issues.apache.org/jira/browse/CAMEL-26338
Project: Camel
Issue Type: Improvement
Components: camel-core
Reporter: shashank
Assignee: shashank
Every processing step of a route runs through its channel ({{DefaultChannel}},
a {{CamelInternalProcessor}}). The channel already does one check per step: it
skips a processor that was disabled at runtime with {{camel cmd
disable-processor}} (the {{DisabledAware}} check in
{{CamelInternalProcessor.process}}). After that check it runs its advices and
calls the error handler of the step, which calls the processor.
*Proposal*
* Give the channel a hook (an SPI), asked next to the disabled check, with the
exchange and the step (its node id). The hook can delay the step or fail it.
* A delay waits there, before the step.
* A failure is raised inside the error handler of the step, where it calls the
step (the three places in {{RedeliveryErrorHandler}} that call its output),
instead of calling it. The disabled check runs before the error handler: an
exception set there would end the exchange without {{onException}}, redelivery
or the dead letter channel. A redelivery asks the hook again.
* With no hook installed, the cost is one check, like the disabled check today.
The hook is installed at runtime, for example by a {{ContextServicePlugin}},
and the routes do not change.
*Why not what exists today*
* An {{InterceptStrategy}} can delay or fail a step without a camel-core
change, but it wraps every processor of every route in one more processor, and
it must be there before the routes are created. The channel already runs a
check per step.
* The advices of the channel ({{CamelInternalProcessorAdvice}}) are added when
the route is created, and they run before the error handler, so a failure there
is not seen by {{onException}}.
* The debuggers ({{Debugger}}, {{BacklogDebugger}}) stop at a step, but only
when debugging is on, and they suspend the exchange instead of delaying or
failing it.
*First user*
camel-chaos (CAMEL-26330): {{delay}} and {{error}} at a step, chosen by a rule
({{step=<processor id pattern>}}), while the application runs. The design
document ({{design/chaos.adoc}}, apache/camel#28539) lists this hook as a
follow-up ticket, next to the send hook (CAMEL-26331). The hook is general, so
other developer tools can use it too.
_Filed with Claude Code on behalf of allthingssecurity._
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)