Luigi De Masi created CAMEL-23776:
-------------------------------------

             Summary: camel-a2a: Add a2aSubTask YAML route step for scoped 
progress events
                 Key: CAMEL-23776
                 URL: https://issues.apache.org/jira/browse/CAMEL-23776
             Project: Camel
          Issue Type: Improvement
         Environment: CAMEL-23063 introduces A2A progress event emission from 
Camel routes through the Simple language function:

  ${a2a:emit('Searching docs...')}

  This allows route authors to emit progress updates, but common use cases 
require several explicit route steps around the actual work being performed. 
For example, a route may need to
  emit a progress event before a search, another event after the search 
succeeds, and another event if the search fails.

  This improvement proposes adding an `a2aSubTask` YAML route step in camel-a2a.

  The `a2aSubTask` step should group one or more nested Camel route steps and 
emit A2A progress events around that grouped work.

  Example:
{code:yaml}
  steps:
    - a2aSubTask:
        emitBefore: "Searching docs..."
        emitAfter: "Docs found: ${body.size()}"
        emitOnError: "Error searching docs: ${exception.message}"
        steps:
          - to:
              uri: elasticsearch:docs?operation=Search

    - a2aSubTask:
        emitBefore: "Drafting answer..."
        emitAfter: "Answer drafted: ${body}"
        emitOnError: "Error drafting answer: ${exception.message}"
        steps:
          - bean:
              ref: answerDraftingService
              method: draft

    - setBody:
        simple: "Final answer: ${body}"
{code}
  The emitted messages should support Simple expressions and should be 
evaluated against the current Exchange at the time each event is emitted.

  Expected behavior:

  * `emitBefore` is evaluated and emitted before the nested steps are executed.
  * `emitAfter` is evaluated and emitted after the nested steps complete 
successfully.
  * `emitOnError` is evaluated and emitted when the nested steps throw an 
exception.
  * `emitOnError` must not swallow, replace, or hide the original exception.
  * All emit fields are optional.
  * The step should support one or more nested Camel route steps.
  * The nested steps should behave like normal route steps.
  * Existing `${a2a:emit(...)}` support remains available and unchanged.

  Implementation notes:

  * This issue should add the A2A-specific route model/reifier/processor 
support needed by `a2aSubTask`.
  * The YAML parser integration should use the generic YAML DSL extension 
mechanism tracked separately.
  * The YAML DSL core should not hard-code the `a2aSubTask` step.

  Non-goals:

  * This issue should not implement the generic YAML DSL extension mechanism.
  * This issue should not add Java DSL or XML DSL syntax for `a2aSubTask`.
  * This issue should not change existing A2A progress emission semantics.
  * This issue should not replace the existing `${a2a:emit(...)}` Simple 
function.
  * This issue should not introduce retry, cancellation, aggregation, or task 
lifecycle behavior.

  Acceptance criteria:

  * `camel-a2a` provides an `a2aSubTask` YAML route step.
  * `a2aSubTask` supports nested `steps`.
  * `emitBefore`, `emitAfter`, and `emitOnError` are optional.
  * Emit message templates are evaluated as Simple expressions.
  * `emitOnError` can access the exception through `${exception.message}`.
  * Exceptions from nested steps continue to propagate normally.
  * Tests cover successful execution, failure execution, no emit fields, only 
one emit field, and multiple nested steps.
  * Documentation includes the new YAML syntax and at least one full route 
example.
            Reporter: Luigi De Masi
            Assignee: Luigi De Masi






--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to