@@ -53,7 +53,7 @@ Those examples contain the following workflow patterns:
53
53
4 . [ External Event Pattern] ( #external-event-pattern )
54
54
5 . [ Child-workflow Pattern] ( #child-workflow-pattern )
55
55
6 . [ Compensation Pattern] ( #compensation-pattern )
56
- 7 . [ Cross -App Pattern] ( #cross -app-pattern )
56
+ 7 . [ Multi -App Pattern] ( #multi -app-pattern )
57
57
58
58
### Chaining Pattern
59
59
In the chaining pattern, a sequence of activities executes in a specific order.
@@ -682,49 +682,49 @@ Key Points:
682
682
4 . Each activity simulates work with a short delay for demonstration purposes
683
683
684
684
685
- ### Cross -App Pattern
685
+ ### Multi -App Pattern
686
686
687
- The cross -app pattern allows workflows to call activities that are hosted in different Dapr applications. This is useful for microservices architectures allowing multiple applications to host activities that can be orchestrated by Dapr Workflows.
687
+ The multi -app pattern allows workflows to call activities that are hosted in different Dapr applications. This is useful for microservices architectures allowing multiple applications to host activities that can be orchestrated by Dapr Workflows.
688
688
689
- The ` CrossAppWorkflow ` class defines the workflow. It demonstrates calling activities in different apps using the ` appId ` parameter in ` WorkflowTaskOptions ` . See the code snippet below:
689
+ The ` MultiAppWorkflow ` class defines the workflow. It demonstrates calling activities in different apps using the ` appId ` parameter in ` WorkflowTaskOptions ` . See the code snippet below:
690
690
``` java
691
- public class CrossAppWorkflow implements Workflow {
691
+ public class MultiAppWorkflow implements Workflow {
692
692
@Override
693
693
public WorkflowStub create () {
694
694
return ctx - > {
695
695
var logger = ctx. getLogger();
696
696
logger. info(" === WORKFLOW STARTING ===" );
697
- logger. info(" Starting CrossAppWorkflow : {}" , ctx. getName());
697
+ logger. info(" Starting MultiAppWorkflow : {}" , ctx. getName());
698
698
logger. info(" Workflow name: {}" , ctx. getName());
699
699
logger. info(" Workflow instance ID: {}" , ctx. getInstanceId());
700
700
701
701
String input = ctx. getInput(String . class);
702
- logger. info(" CrossAppWorkflow received input: {}" , input);
702
+ logger. info(" MultiAppWorkflow received input: {}" , input);
703
703
logger. info(" Workflow input: {}" , input);
704
704
705
705
// Call an activity in another app by passing in an active appID to the WorkflowTaskOptions
706
- logger. info(" Calling cross -app activity in 'app2'..." );
707
- logger. info(" About to call cross -app activity in app2..." );
708
- String crossAppResult = ctx. callActivity(
706
+ logger. info(" Calling multi -app activity in 'app2'..." );
707
+ logger. info(" About to call multi -app activity in app2..." );
708
+ String multiAppResult = ctx. callActivity(
709
709
App2TransformActivity . class. getName(),
710
710
input,
711
711
new WorkflowTaskOptions (" app2" ),
712
712
String . class
713
713
). await();
714
714
715
715
// Call another activity in a different app
716
- logger. info(" Calling cross -app activity in 'app3'..." );
717
- logger. info(" About to call cross -app activity in app3..." );
716
+ logger. info(" Calling multi -app activity in 'app3'..." );
717
+ logger. info(" About to call multi -app activity in app3..." );
718
718
String finalResult = ctx. callActivity(
719
719
App3FinalizeActivity . class. getName(),
720
- crossAppResult ,
720
+ multiAppResult ,
721
721
new WorkflowTaskOptions (" app3" ),
722
722
String . class
723
723
). await();
724
- logger. info(" Final cross -app activity result: {}" , finalResult);
725
- logger. info(" Final cross -app activity result: {}" , finalResult);
724
+ logger. info(" Final multi -app activity result: {}" , finalResult);
725
+ logger. info(" Final multi -app activity result: {}" , finalResult);
726
726
727
- logger. info(" CrossAppWorkflow finished with: {}" , finalResult);
727
+ logger. info(" MultiAppWorkflow finished with: {}" , finalResult);
728
728
logger. info(" === WORKFLOW COMPLETING WITH: {} ===" , finalResult);
729
729
ctx. complete(finalResult);
730
730
};
@@ -784,31 +784,31 @@ public class App3FinalizeActivity implements WorkflowActivity {
784
784
785
785
** Important Limitations:**
786
786
- ** Cross-app calls are currently supported for activities only**
787
- - ** Child workflow cross -app calls (suborchestration) are NOT supported**
787
+ - ** Child workflow multi -app calls (suborchestration) are NOT supported**
788
788
- The app ID must match the Dapr application ID of the target service
789
789
790
790
** Running the Cross-App Example:**
791
791
792
792
This example requires running multiple Dapr applications simultaneously. You'll need to run the following commands in separate terminals:
793
793
794
- 1 . ** Start the main workflow worker (crossapp -worker):**
794
+ 1 . ** Start the main workflow worker (multiapp -worker):**
795
795
``` sh
796
- dapr run --app-id crossapp -worker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.crossapp.CrossAppWorker
796
+ dapr run --app-id multiapp -worker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.multiapp.MultiAppWorker
797
797
```
798
798
799
799
2 . ** Start app2 worker (handles App2TransformActivity):**
800
800
``` sh
801
- dapr run --app-id app2 --resources-path ./components/workflows --dapr-grpc-port 50002 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.crossapp .App2Worker
801
+ dapr run --app-id app2 --resources-path ./components/workflows --dapr-grpc-port 50002 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.multiapp .App2Worker
802
802
```
803
803
804
804
3 . ** Start app3 worker (handles App3FinalizeActivity):**
805
805
``` sh
806
- dapr run --app-id app3 --resources-path ./components/workflows --dapr-grpc-port 50003 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.crossapp .App3Worker
806
+ dapr run --app-id app3 --resources-path ./components/workflows --dapr-grpc-port 50003 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.multiapp .App3Worker
807
807
```
808
808
809
809
4 . ** Run the workflow client:**
810
810
``` sh
811
- java -Djava.util.logging.ConsoleHandler.level=FINE -Dio.dapr.durabletask.level=FINE -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.crossapp.CrossAppWorkflowClient " Hello World"
811
+ java -Djava.util.logging.ConsoleHandler.level=FINE -Dio.dapr.durabletask.level=FINE -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.multiapp.MultiAppWorkflowClient " Hello World"
812
812
```
813
813
814
814
** Expected Output:**
@@ -819,15 +819,15 @@ The client will show:
819
819
Input: Hello World
820
820
Created DaprWorkflowClient successfully
821
821
Attempting to start new workflow...
822
- Started a new cross -app workflow with instance ID: 001113f3-b9d9-438c-932a-a9a9b70b9460
822
+ Started a new multi -app workflow with instance ID: 001113f3-b9d9-438c-932a-a9a9b70b9460
823
823
Waiting for workflow completion...
824
824
Workflow instance with ID: 001113f3-b9d9-438c-932a-a9a9b70b9460 completed with result: HELLO WORLD [TRANSFORMED BY APP2] [FINALIZED BY APP3]
825
825
```
826
826
827
827
The workflow demonstrates:
828
- 1 . The workflow starts in the main worker (crossapp -worker)
829
- 2 . Calls an activity in 'app2' using cross -app functionality
830
- 3 . Calls an activity in 'app3' using cross -app functionality
828
+ 1 . The workflow starts in the main worker (multiapp -worker)
829
+ 2 . Calls an activity in 'app2' using multi -app functionality
830
+ 3 . Calls an activity in 'app3' using multi -app functionality
831
831
4 . The workflow completes with the final result from all activities
832
832
833
833
This pattern is particularly useful for:
0 commit comments