Skip to content

feat(workflows): add WorkflowOrdering to NewWorkflowOptions - #1927

Open
JoshVanL wants to merge 2 commits into
dapr:masterfrom
JoshVanL:workflow-ordering-key
Open

JoshVanL wants to merge 2 commits into
dapr:masterfrom
JoshVanL:workflow-ordering-key

Conversation

@JoshVanL

@JoshVanL JoshVanL commented Dec 2, 2026

Copy link
Copy Markdown
Member

NewWorkflowOptions.setOrdering(new WorkflowOrdering(key, policy)) queues
the workflow behind the other workflows of its app started with the same
key. OrderingFailurePolicy (CONTINUE, BLOCK, CANCEL) sets what the
workflow does when the workflow before it did not complete successfully.
WorkflowOrdering(key) defaults to CONTINUE.

NewOrchestrationInstanceOptions carries the proto WorkflowOrdering to
DurableTaskGrpcClient, which sets CreateInstanceRequest.ordering only
when one is given.

Moves durabletask.proto.baseurl in pom.xml to durabletask-protobuf
v0.8.0, the first release with WorkflowOrdering.

Signed-off-by: joshvanl me@joshvanl.dev

NewWorkflowOptions.setOrdering(new WorkflowOrdering(key, policy)) queues
the workflow behind the other workflows of its app started with the same
key. OrderingFailurePolicy (CONTINUE, BLOCK, CANCEL) sets what the
workflow does when the workflow before it did not complete successfully.
WorkflowOrdering(key) defaults to CONTINUE.

NewOrchestrationInstanceOptions carries the proto WorkflowOrdering to
DurableTaskGrpcClient, which sets CreateInstanceRequest.ordering only
when one is given.

Moves durabletask.proto.baseurl in pom.xml to durabletask-protobuf
v0.8.0, the first release with WorkflowOrdering.

Signed-off-by: joshvanl <me@joshvanl.dev>
@JoshVanL
JoshVanL requested review from a team as code owners December 2, 2026 16:05
Copilot AI balanced review requested due to automatic review settings December 2, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new scheduling API lacks the required runnable example and real-runtime integration tests covering same-key ordering and failure policies.

2 open issues
What changed in this PR

Adds workflow ordering to the Java SDK, allowing same-key workflows to queue with configurable predecessor-failure handling.

Changes:

  • Adds ordering options with CONTINUE, BLOCK, and CANCEL policies.
  • Passes ordering through workflow scheduling to gRPC requests.
  • Updates protobuf definitions to v0.8.0 and adds request-mapping tests.
File Description
sdk-workflows/​src/​test/​java/​io/​dapr/​workflows/​task/​DurableTaskGrpcClientScheduleTest.java Tests ordering presence and omission in requests.
sdk-workflows/​src/​test/​java/​io/​dapr/​workflows/​client/​DaprWorkflowClientTest.java Tests ordering conversion during scheduling.
sdk-workflows/​src/​main/​java/​io/​dapr/​workflows/​task/​client/​NewOrchestrationInstanceOptions.java Carries protobuf ordering options.
sdk-workflows/​src/​main/​java/​io/​dapr/​workflows/​task/​client/​DurableTaskGrpcClient.java Adds ordering to creation requests when supplied.
sdk-workflows/​src/​main/​java/​io/​dapr/​workflows/​client/​WorkflowOrdering.java Defines ordering keys and the default policy.
sdk-workflows/​src/​main/​java/​io/​dapr/​workflows/​client/​OrderingFailurePolicy.java Defines and maps failure policies.
sdk-workflows/​src/​main/​java/​io/​dapr/​workflows/​client/​NewWorkflowOptions.java Exposes workflow ordering configuration.
sdk-workflows/​src/​main/​java/​io/​dapr/​workflows/​client/​DaprWorkflowClient.java Converts ordering into orchestration options.
pom.xml Pins Durable Task protobuf definitions to v0.8.0.

Review effort: Balanced

* @param ordering the ordering of the new workflow
* @return this {@link NewWorkflowOptions} object
*/
public NewWorkflowOptions setOrdering(WorkflowOrdering ordering) {
Comment on lines +223 to +225
if (options.getOrdering() != null) {
builder.setOrdering(options.getOrdering());
}
examples/workflows/ordering processes the orders of one customer in
sequence under one key, then shows the CANCEL policy terminating an
order whose predecessor failed. Its README runs the worker and client
as mechanical-markdown steps. Like the schedules example, it is not in
the validation workflow, which runs against the Dapr 1.19 release.

WorkflowOrderingIT runs against the edge images, tagged dapr-head like
WorkflowSchedulesIT. It checks that a same-key workflow stays pending
while the one before it runs, and the CONTINUE, CANCEL and BLOCK
policies after a failure, including a purge releasing a blocked
workflow.

WorkflowOrderingTest covers the key-only constructor defaulting to
CONTINUE and the mapping of every OrderingFailurePolicy to its proto
value.

Signed-off-by: joshvanl <me@joshvanl.dev>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 18:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The example’s timer-based sequencing can produce statuses that contradict the README, and the new README is not registered for mechanical validation.

4 open issues

Review effort: Balanced

Comment on lines +40 to +41
client.waitForWorkflowStart("order-1", TIMEOUT, false);
System.out.printf("order-1 is %s, order-2 is %s%n", status(client, "order-1"), status(client, "order-2"));
Comment on lines +68 to +69
<!-- STEP
name: Run Workflow Ordering Worker
@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.01%. Comparing base (22c2a9d) to head (059bf83).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1927      +/-   ##
============================================
+ Coverage     82.89%   83.01%   +0.12%     
- Complexity     3977     3998      +21     
============================================
  Files           360      363       +3     
  Lines         11971    12003      +32     
  Branches       1339     1341       +2     
============================================
+ Hits           9923     9964      +41     
+ Misses         1546     1537       -9     
  Partials        502      502              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@javier-aliaga javier-aliaga left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@JoshVanL can you fix copilots comments?

This branch has not been deployed

No deployments
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.

3 participants