diff --git a/temporal-sdk/src/main/java/io/temporal/internal/client/WorkflowClientRequestFactory.java b/temporal-sdk/src/main/java/io/temporal/internal/client/WorkflowClientRequestFactory.java index c8d9a3cca..dbab7074a 100644 --- a/temporal-sdk/src/main/java/io/temporal/internal/client/WorkflowClientRequestFactory.java +++ b/temporal-sdk/src/main/java/io/temporal/internal/client/WorkflowClientRequestFactory.java @@ -210,6 +210,9 @@ SignalWithStartWorkflowExecutionRequest.Builder newSignalWithStartWorkflowExecut request.setVersioningOverride(startParameters.getVersioningOverride()); } + if (startParameters.hasPriority()) { + request.setPriority(startParameters.getPriority()); + } return request; } diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/PriorityInfoTest.java b/temporal-sdk/src/test/java/io/temporal/workflow/PriorityInfoTest.java index 339c5f103..1779295e9 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/PriorityInfoTest.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/PriorityInfoTest.java @@ -6,11 +6,13 @@ import io.temporal.activity.ActivityInterface; import io.temporal.activity.ActivityOptions; import io.temporal.client.WorkflowOptions; +import io.temporal.client.WorkflowStub; import io.temporal.common.Priority; import io.temporal.testing.internal.SDKTestWorkflowRule; import io.temporal.workflow.shared.TestWorkflows; import io.temporal.workflow.shared.TestWorkflows.TestWorkflow1; import java.time.Duration; +import java.util.UUID; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -20,7 +22,10 @@ public class PriorityInfoTest { @Rule public SDKTestWorkflowRule testWorkflowRule = SDKTestWorkflowRule.newBuilder() - .setWorkflowTypes(TestPriority.class, TestPriorityChildWorkflow.class) + .setWorkflowTypes( + TestPriority.class, + TestPriorityChildWorkflow.class, + TestSignalWithStartPriorityWorkflowImpl.class) .setActivityImplementations(new PriorityActivitiesImpl()) .build(); @@ -44,6 +49,24 @@ public void testPriority() { assertEquals("5:tenant-123:2.5", result); } + @Test + public void testPriorityWithSignalWithStart() { + WorkflowStub stub = + testWorkflowRule + .getWorkflowClient() + .newUntypedWorkflowStub( + "TestSignalWithStartPriorityWorkflow", + WorkflowOptions.newBuilder() + .setWorkflowId("test-signal-with-start-priority-" + UUID.randomUUID()) + .setTaskQueue(testWorkflowRule.getTaskQueue()) + .setPriority(Priority.newBuilder().setPriorityKey(2).build()) + .build()); + stub.signalWithStart( + "mySignal", new Object[] {"signalArg"}, new Object[] {testWorkflowRule.getTaskQueue()}); + String result = stub.getResult(String.class); + assertEquals("2:null:0.0", result); + } + @ActivityInterface public interface PriorityActivities { String activity1(String a1); @@ -131,4 +154,32 @@ public String execute(String taskQueue) { + workflowPriority.getFairnessWeight(); } } + + @WorkflowInterface + public interface TestSignalWithStartPriorityWorkflow { + @WorkflowMethod + String execute(String taskQueue); + + @SignalMethod + void mySignal(String arg); + } + + public static class TestSignalWithStartPriorityWorkflowImpl + implements TestSignalWithStartPriorityWorkflow { + + private boolean received = false; + + @Override + public String execute(String taskQueue) { + Workflow.await(() -> received); + Priority priority = Workflow.getInfo().getPriority(); + String key = priority.getFairnessKey() != null ? priority.getFairnessKey() : "null"; + return priority.getPriorityKey() + ":" + key + ":" + priority.getFairnessWeight(); + } + + @Override + public void mySignal(String arg) { + received = true; + } + } } diff --git a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java index b62f021a3..4e4bbf336 100644 --- a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java +++ b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java @@ -1657,6 +1657,9 @@ public void signalWithStartWorkflowExecution( if (!r.getLinksList().isEmpty()) { startRequest.addAllLinks(r.getLinksList()); } + if (r.hasPriority()) { + startRequest.setPriority(r.getPriority()); + } StartWorkflowExecutionResponse startResult = startWorkflowExecutionImpl(