I know we can call child workflows from a parent workflow. But can can one workflow just orchestrate some other workflows and those workflows can have their own activities without going via the child workflow creation route?
Hello,
To start or query other workflows, you have to do it from an activity.
From workflow code you can cancel or signal external workflows. (eg in Java creating an ExternalWorkflowStub or in ts getting the handler sigh getExternalWorkflowHandle)
What is your use case for not using child workflows? they are just normal workflows with activities as well.
Hi Antonio,
I am already using activities from my current workflow. I was having a scenario where say I already have 5 activities which I have spawned from one workflow. But the business usecase was that I have say 50-60 organisations and I need to use those same 5 activities for all orgs since functionally all orgs want the same code that’s written in those 5 activities. However currently I have a master workflow say workflow1 inside which I have loop for those 50-60 orgs and for each org I want to call the same 5 activities. These 5 activities are not currently in the master workflow but in a org specific workflow say workflow2 and inside the loop of workflow1 I want to call workflow2 50-60 times.
I read below from @maxim the purpose of creating child workflows and hence posted this query
basically this is my setup
public class MasterWorkflowImpl {
//have 50 orgs
for(String org : orgList) {
//I need the same activities here as in the workflow below.
}
}
public class OrgWorkflowImpl {
//I am calling all the 5-6 activities here where the actual business logic and database code stuff is.
}
Here are a couple of links that can be useful if you use child workflows:
- Parent Close Policy: Workflows | Temporal Documentation
- It might it worth having a look at this example samples-java/src/main/java/io/temporal/samples/batch/iterator at main · temporalio/samples-java · GitHub,
Let me know if you have more questions.
Ok. to make it precise. Is there any other way that from 1 workflow I can call another workflow without creating child workflows or activities??
Re-pasting my scenario setup:
public class MasterWorkflowImpl {
//have 50 orgs
for(String org : orgList) {
//I need the same activities here as in the workflow below.
}
}
public class OrgWorkflowImpl {
//I am calling all the 5-6 activities here where the actual business logic and database code stuff is.
}
Are you asking for the ability to share activities between two workflow types?
Activities are not linked to any workflow type already. So it is OK to have two workflows calling them same set of activities.