Start workflow from a worker?

I have 2 workflows A and B. At the end of workflow A I’d like to kick off workflow B with the results of workflow A. What is the best way to do this? It doesn’t look like I have access to the zeebeClient within the worker interface (Java implementation)

1 Like

I’m not sure of the details with the Java client, but there is always a way.

If I were doing it like this example: https://docs.zeebe.io/clients/java-client-examples/job-worker-open.html

I’d pass the Zeebe client into the constructor of the job handler to get a reference to it there.

Otherwise, you could use the call activity symbol: https://docs.zeebe.io/bpmn-workflows/call-activities/call-activities.html.

HTH,
Josh

@rudyj03 are you using Spring Boot? and the Spring Boot Starter for Zeebe? There you can auto wire the Zeebe Client and you can use it.

1 Like

Thanks for the suggestions!

Yes I am using spring boot and the starter. I was able to get this working after Autowiring the client. Curious about the Call Activity symbol too, I will have to try it out.

1 Like

@rudyj03 I totally recommend you to check Call Activity as it will give you more benefits with correlation of which workflow started the sub workflow, it is also more clear from the graphical representation.

Thanks, the Call Activity works well! The graphical representation is also better. What is the best way to call the Call Activity multiple times? In my case, workflow A results in multiple notifications that workflow B is responsible for sending. Edit: Perhaps for my specific situation it’s just better to start new workflow B instances.

My working solution right now has workflow A publish multiple messages (one per notification) that workflow B listens for with a Message Start Event. Works well enough, but not as graphically nice of a representation.