Skip to content

Confusing about the workflow context with fork task #1220

@NguyenThiHanhVi-future-aavn

Description

During using the sdk-java I see the confusion of the workflow context when run the fork task
Here is my workflow dsl
parallelEnrichment: input: from: ${ $context.order } fork: compete: true branches: - pricingEnrichment: input: from: ${ . } set: subtotal: ${ .amount } tax: 20.00 total: ${ .amount + 20.00 } output: as: '${ $input + { "pricing": $output } }' export: as: '${ { "pricing": $output } }' - customerEnrichment: input: from: ${ .customer } set: loyaltyTier: "gold" discountPct: 5 output: as: '${ $input + { "profile": $output } }' export: as: '${ { "customer": $output } }' - riskAssessment: input: from: ${ . } set: riskScore: 12 riskBand: "low" output: as: '${ $input + { "risk": $output } }' export: as: '${ { "risk": $output } }'

  1. with compete false
    The workflow output is the combined output from all branches but context is not, it is always the context from last updated branch not the combined context from all branches?
  2. with compete flag true
    When first complete branch completed and trigger complete to fork task (state COMPLETED) then the other branch get FAULTED, is fork task status be influented by the failed result or still keep COMPLETED?
  3. also with compete flag true
    The workflow output and context sometimes get from different branch like the log below
    [io.serverlessworkflow.impl.BlockingExample.main()] INFO io.serverlessworkflow.impl.BlockingExample - Workflow context: { "pricing" : { "pricing" : { "subtotal" : null, "tax" : 20.0, "total" : 20.0 } } } [io.serverlessworkflow.impl.BlockingExample.main()] INFO io.serverlessworkflow.impl.BlockingExample - Final output: { "profile" : { "loyaltyTier" : "gold", "discountPct" : 5 } }
    I expect the output and the context should be get from the branch winner who completed first. But the test shows output comes from first completed branch and context comes from last updated branch?
    Please help to confirm what should I follow.
    Thanks for your support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions