diff --git a/durabletask-client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java b/durabletask-client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java index 032843660f..785e2d7678 100644 --- a/durabletask-client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java +++ b/durabletask-client/src/main/java/io/dapr/durabletask/TaskOrchestrationExecutor.java @@ -424,18 +424,6 @@ public Task callActivity( scheduleTaskBuilder.setInput(StringValue.of(serializedInput)); } - // Add router information for cross-app routing - if (hasSourceAppId() && hasTargetAppId(options)) { - String targetAppId = options.getAppID(); - scheduleTaskBuilder.setRouter(Orchestration.TaskRouter.newBuilder() - .setSourceAppID(this.appId) - .setTargetAppID(targetAppId) - .build()); - this.logger.fine(() -> String.format( - "cross app routing detected: source=%s, target=%s", - this.appId, targetAppId)); - } - // Set history propagation scope if specified if (options != null && options.hasHistoryPropagationScope()) { scheduleTaskBuilder.setHistoryPropagationScope( @@ -449,10 +437,14 @@ public Task callActivity( .setId(id) .setScheduleTask(scheduleTaskBuilder); if (hasSourceAppId() && hasTargetAppId(options)) { + String targetAppId = options.getAppID(); actionBuilder.setRouter(Orchestration.TaskRouter.newBuilder() .setSourceAppID(this.appId) - .setTargetAppID(options.getAppID()) + .setTargetAppID(targetAppId) .build()); + this.logger.fine(() -> String.format( + "cross app routing detected: source=%s, target=%s", + this.appId, targetAppId)); } this.pendingActions.put(id, actionBuilder.build()); @@ -597,22 +589,6 @@ public Task callSubOrchestrator( } createSubOrchestrationActionBuilder.setInstanceId(instanceId); - // Add router information for cross-app routing of sub-orchestrations - if (hasSourceAppId()) { - Orchestration.TaskRouter.Builder routerBuilder = Orchestration.TaskRouter.newBuilder() - .setSourceAppID(this.appId); - - // Add target app ID if specified in options - if (hasTargetAppId(options)) { - routerBuilder.setTargetAppID(options.getAppID()); - this.logger.fine(() -> String.format( - "cross app sub-orchestration routing detected: source=%s, target=%s", - this.appId, options.getAppID())); - } - - createSubOrchestrationActionBuilder.setRouter(routerBuilder.build()); - } - // Set history propagation scope if specified if (options != null && options.hasHistoryPropagationScope()) { createSubOrchestrationActionBuilder.setHistoryPropagationScope( @@ -632,6 +608,9 @@ public Task callSubOrchestrator( .setSourceAppID(this.appId); if (hasTargetAppId(options)) { actionRouterBuilder.setTargetAppID(options.getAppID()); + this.logger.fine(() -> String.format( + "cross app sub-orchestration routing detected: source=%s, target=%s", + this.appId, options.getAppID())); } actionBuilder.setRouter(actionRouterBuilder.build()); } diff --git a/durabletask-client/src/test/java/io/dapr/durabletask/HistoryPropagationIntegrationTest.java b/durabletask-client/src/test/java/io/dapr/durabletask/HistoryPropagationIntegrationTest.java index bfecf626e3..7f2d183a04 100644 --- a/durabletask-client/src/test/java/io/dapr/durabletask/HistoryPropagationIntegrationTest.java +++ b/durabletask-client/src/test/java/io/dapr/durabletask/HistoryPropagationIntegrationTest.java @@ -527,10 +527,6 @@ void historyPropagation_combinedWithCrossAppRouting_bothWork() { OrchestratorActions.CreateChildWorkflowAction createChild = action.getCreateChildWorkflow(); // Verify BOTH cross-app routing and history propagation are set - assertTrue(createChild.hasRouter()); - assertEquals(sourceAppId, createChild.getRouter().getSourceAppID()); - assertEquals(targetAppId, createChild.getRouter().getTargetAppID()); - assertTrue(createChild.hasHistoryPropagationScope()); assertEquals(Orchestration.HistoryPropagationScope.HISTORY_PROPAGATION_SCOPE_LINEAGE, createChild.getHistoryPropagationScope()); diff --git a/durabletask-client/src/test/java/io/dapr/durabletask/SubOrchestrationCrossAppTest.java b/durabletask-client/src/test/java/io/dapr/durabletask/SubOrchestrationCrossAppTest.java index 9ed6bb47e7..854ac2012d 100644 --- a/durabletask-client/src/test/java/io/dapr/durabletask/SubOrchestrationCrossAppTest.java +++ b/durabletask-client/src/test/java/io/dapr/durabletask/SubOrchestrationCrossAppTest.java @@ -151,16 +151,11 @@ void callSubOrchestrator_withTargetAppId_setsRouterOnAction() { OrchestratorActions.WorkflowAction action = actions.get(0); assertTrue(action.hasCreateChildWorkflow()); - // Verify the CreateSubOrchestrationAction has the router OrchestratorActions.CreateChildWorkflowAction createSub = action.getCreateChildWorkflow(); assertEquals(subOrchestratorName, createSub.getName()); assertEquals("child-instance-1", createSub.getInstanceId()); - assertTrue(createSub.hasRouter()); - assertEquals(sourceAppId, createSub.getRouter().getSourceAppID()); - assertTrue(createSub.getRouter().hasTargetAppID()); - assertEquals(targetAppId, createSub.getRouter().getTargetAppID()); - // Verify the OrchestratorAction also has the router + // Verify the OrchestratorAction has the router assertTrue(action.hasRouter()); assertEquals(sourceAppId, action.getRouter().getSourceAppID()); assertTrue(action.getRouter().hasTargetAppID()); @@ -198,13 +193,7 @@ void callSubOrchestrator_withoutTargetAppId_setsRouterWithSourceOnly() { OrchestratorActions.WorkflowAction action = actions.get(0); assertTrue(action.hasCreateChildWorkflow()); - // Router should have source only, no target - OrchestratorActions.CreateChildWorkflowAction createSub = action.getCreateChildWorkflow(); - assertTrue(createSub.hasRouter()); - assertEquals(sourceAppId, createSub.getRouter().getSourceAppID()); - assertFalse(createSub.getRouter().hasTargetAppID()); - - // OrchestratorAction router should also have source only + // OrchestratorAction router should have source only, no target assertTrue(action.hasRouter()); assertEquals(sourceAppId, action.getRouter().getSourceAppID()); assertFalse(action.getRouter().hasTargetAppID()); @@ -239,8 +228,6 @@ void callSubOrchestrator_withNullAppId_noRouterSet() { assertTrue(action.hasCreateChildWorkflow()); // No router should be set when appId is null - OrchestratorActions.CreateChildWorkflowAction createSub = action.getCreateChildWorkflow(); - assertFalse(createSub.hasRouter()); assertFalse(action.hasRouter()); } @@ -489,11 +476,6 @@ void crossAppSubOrchestration_fullFlow_routersCorrectlySet() { assertEquals(subOrchestratorName, createSub.getName()); assertEquals("child-id-1", createSub.getInstanceId()); - // Verify cross-app router on the sub-orchestration action - assertTrue(createSub.hasRouter()); - assertEquals(sourceAppId, createSub.getRouter().getSourceAppID()); - assertEquals(targetAppId, createSub.getRouter().getTargetAppID()); - // Verify cross-app router on the OrchestratorAction envelope assertTrue(subAction.hasRouter()); assertEquals(sourceAppId, subAction.getRouter().getSourceAppID()); @@ -527,7 +509,6 @@ void callSubOrchestrator_withEmptyAppId_noRouterSet() { assertTrue(action.hasCreateChildWorkflow()); // No router should be set when appId is empty - assertFalse(action.getCreateChildWorkflow().hasRouter()); assertFalse(action.hasRouter()); } @@ -569,9 +550,8 @@ void callSubOrchestrator_withRetryPolicyAndAppId_setsRouterAndRetries() { OrchestratorActions.WorkflowAction action = actions.get(0); assertTrue(action.hasCreateChildWorkflow()); - OrchestratorActions.CreateChildWorkflowAction createSub = action.getCreateChildWorkflow(); - assertTrue(createSub.hasRouter()); - assertEquals(sourceAppId, createSub.getRouter().getSourceAppID()); - assertEquals(targetAppId, createSub.getRouter().getTargetAppID()); + assertTrue(action.hasRouter()); + assertEquals(sourceAppId, action.getRouter().getSourceAppID()); + assertEquals(targetAppId, action.getRouter().getTargetAppID()); } }