Expected Behavior
The Java workflow client can require an instance ID to be unique when scheduling a workflow. When enabled, scheduling a workflow whose instance ID already exists fails with a gRPC ALREADY_EXISTS error, whether the existing instance is running or completed. The caller then decides what to do instead of the runtime silently restarting a completed instance.
Actual Behavior
The Java SDK has no way to request this. Scheduling a workflow with an instance ID that belongs to a completed instance restarts that instance. The runtime already supports the flag: the enforceUniqueInstanceId field on CreateInstanceRequest was merged in durabletask-protobuf #55, durabletask-go #116, and dapr #10379, and is released in durabletask-go v0.14.0. The Java SDK never sets it.
Steps to Reproduce the Problem
- Schedule a workflow with a fixed instance ID and wait for it to complete.
- Schedule a workflow again with the same instance ID.
- The completed instance is restarted. There is no option on
NewWorkflowOptions to reject the duplicate instead.
Proposed Implementation
The proto field is already available at build time — durabletask.proto.baseurl in pom.xml tracks dapr/durabletask-protobuf/main, which contains the field. Four layers need the option plumbed through:
durabletask-client/.../NewOrchestrationInstanceOptions.java — add an enforceUniqueInstanceId field with setter and getter, alongside the existing startTime/appID fields.
durabletask-client/.../DurableTaskGrpcClient.java (around line 204) — call builder.setEnforceUniqueInstanceId(...) on the CreateInstanceRequest.Builder, mirroring how setScheduledStartTimestamp is set.
sdk-workflows/.../client/NewWorkflowOptions.java — add the same enforceUniqueInstanceId field with setter and getter.
sdk-workflows/.../client/DaprWorkflowClient.java fromNewWorkflowOptions() (around line 517) — map the option onto NewOrchestrationInstanceOptions.
The error surfacing is already handled: DaprWorkflowClient.mapAlreadyExists() maps the gRPC ALREADY_EXISTS status to a typed exception.
Scope also includes unit tests for the option mapping and the request builder. An example update is optional.
Requires a Dapr runtime that includes the feature (built with durabletask-go v0.14.0 or later).
Release Note
RELEASE NOTE: ADD enforceUniqueInstanceId option to fail workflow scheduling when the instance ID already exists.
Expected Behavior
The Java workflow client can require an instance ID to be unique when scheduling a workflow. When enabled, scheduling a workflow whose instance ID already exists fails with a gRPC
ALREADY_EXISTSerror, whether the existing instance is running or completed. The caller then decides what to do instead of the runtime silently restarting a completed instance.Actual Behavior
The Java SDK has no way to request this. Scheduling a workflow with an instance ID that belongs to a completed instance restarts that instance. The runtime already supports the flag: the
enforceUniqueInstanceIdfield onCreateInstanceRequestwas merged in durabletask-protobuf #55, durabletask-go #116, and dapr #10379, and is released in durabletask-go v0.14.0. The Java SDK never sets it.Steps to Reproduce the Problem
NewWorkflowOptionsto reject the duplicate instead.Proposed Implementation
The proto field is already available at build time —
durabletask.proto.baseurlinpom.xmltracksdapr/durabletask-protobuf/main, which contains the field. Four layers need the option plumbed through:durabletask-client/.../NewOrchestrationInstanceOptions.java— add anenforceUniqueInstanceIdfield with setter and getter, alongside the existingstartTime/appIDfields.durabletask-client/.../DurableTaskGrpcClient.java(around line 204) — callbuilder.setEnforceUniqueInstanceId(...)on theCreateInstanceRequest.Builder, mirroring howsetScheduledStartTimestampis set.sdk-workflows/.../client/NewWorkflowOptions.java— add the sameenforceUniqueInstanceIdfield with setter and getter.sdk-workflows/.../client/DaprWorkflowClient.javafromNewWorkflowOptions()(around line 517) — map the option ontoNewOrchestrationInstanceOptions.The error surfacing is already handled:
DaprWorkflowClient.mapAlreadyExists()maps the gRPCALREADY_EXISTSstatus to a typed exception.Scope also includes unit tests for the option mapping and the request builder. An example update is optional.
Requires a Dapr runtime that includes the feature (built with durabletask-go v0.14.0 or later).
Release Note
RELEASE NOTE: ADD
enforceUniqueInstanceIdoption to fail workflow scheduling when the instance ID already exists.