Skip to content

Add payload-carrying wakeup to the flow engine via MessagePayload - #229

Merged
akashdw merged 2 commits into
mainfrom
ad/flow-wakeup-with-payload
Jul 17, 2026
Merged

Add payload-carrying wakeup to the flow engine via MessagePayload#229
akashdw merged 2 commits into
mainfrom
ad/flow-wakeup-with-payload

Conversation

@akashdw

@akashdw akashdw commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Pull Request type

  • Bugfix
  • [ x] Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes (Please run ./gradlew build --write-locks to refresh dependencies)
  • Other (please describe):

NOTE: Please remember to run ./gradlew spotlessApply to fix any format violations.

Changes in this PR


Add payload-carrying wakeup to the flow engine

What

Flow-engine wakeups today carry only an int code. This adds an optional structured payload that rides alongside the code, from the wakeup entrypoint all the way down to the task's execute, so a step can read caller-supplied context when it wakes up instead of inferring everything from the code.

How

  • MessagePayload — new polymorphic interface with a DefaultMessagePayload subtype. A MessagePayload.DEFAULT sentinel is used everywhere in place of null, so no nullable payloads flow through the engine.
  • Threaded through the actor modelAction.FlowWakeUp / TaskWakeUp / TaskActivate / TaskPing carry the payload; GroupActorFlowActorTaskActor pass it down. Task gets a messagePayload scratch field, set before execute and reset in a finally (same handoff shape as the existing code field), so a payload never leaks into the task's cloneTask serialization.
  • Kept clubbed with the existing path — no new action type. FlowExecutor.wakeUp / FlowOperation.wakeUp gain a payload overload; the int-only overloads delegate with MessagePayload.DEFAULT. FlowActor dedup preserves current behavior for the default (code=0, DEFAULT payload) case, so internal polling is unchanged.
  • RESTRestBasedFlowOperation and FlowEngineController get payload-carrying endpoints for both flow-ref (/tasks/{taskReference}/message/{code}) and workflow-ref (.../steps/{stepId}/message/{code}) addressing, routing cross-node the same way as the existing wakeup.

Notes

  • Delivery guarantee (caller confirming delivery via the HTTP response) and payload batching are intentionally out of scope here.
  • Tests mirror existing conventions in TaskActorTest, FlowActorTest, GroupActorTest, FlowExecutorTest, FlowEngineControllerTest, RestBasedFlowOperationTest, plus round-trip serde in MessagePayloadTest.

@rdeepak2002 rdeepak2002 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the change!

@akashdw
akashdw merged commit 441149c into main Jul 17, 2026
1 check passed

@praneethy91 praneethy91 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants