Multiple child workflows

43 views
Skip to first unread message

Luca

unread,
Jun 29, 2021, 9:16:05 AM6/29/21
to nflow-users
Hello everyone,

I'm writing you because I'm facing some difficulties trying to add childworkflows into the main one.
So, the idea is to generate n childs into one precise step inside the parent workflow and to make all these childs refer to a specific class. 
The problem is that when I do this into the parent workflow:

public NextAction components(StateExecution execution) {
for (int i = 0; i < execution.getVariable(COMPONENTS, Integer.class); i++) {
WorkflowInstance childWorkflow = execution.workflowInstanceBuilder()
.setType(ComponentChildWorkflow.TYPE)
.build();
execution.addChildWorkflows(childWorkflow);
}
return NextAction.moveToState(State.poll, "Next iteration");
}

It always says: No workflow definition found for type [componentChildWorkflow]

How can I start n childworkflows to run them  asynchronously?

Thank you very much,
Luca


nflow-users

unread,
Jun 29, 2021, 2:56:05 PM6/29/21
to nflow-users
Hello Luca,

Looks like your workflow definition (ComponentChildWorkflow) is not registered to WorkflowDefinitionService neither by WorkflowDefinitionClassNameScanner, WorkflowDefinitionSpringBeanScanner, nor manually. I suggest you have a look at that.

br, Edvard

Luca

unread,
Jun 30, 2021, 3:00:02 AM6/30/21
to nflow-users
Hi Edward,

Thanks for your suggestion, adding the child workflow as a bean in this way resolved the problem:

@Bean
public ComponentChildWorkflow componentChildWorkflow() {
return new ComponentChildWorkflow();
}

Cheers,
Luca
Reply all
Reply to author
Forward
0 new messages