Asynchronous Sub Process in Zeebe

Hello everyone. I am new to ZEEBE and am stuck with a problem.

I have a main process. At the end of the process, I want to call another process, but don’t want to wait for that process to complete. I just want that the main process triggers that process and ends. Currently I am able to achieve something of that sort by using a service task, where I have an http worker configured. I pass the URL as an asynchronous endpoint to the other process I want to trigger. This setup works fine sometimes, but sometimes I get GRPC timeout exception. Is there a way I can achieve my requirement with a better fail proof performance? I tried using call activity but it waits for the called activity to complete, and only then returns to the main process, so doesn’t suit my requirement. Any help would be greatly appreciated. Thank you.

Hey @Tanmai_Mukku

thanks for using Zeebe!

Did you considered message throw events and message catch events?

Maybe this helps.

Greets
Chris

Hi Zelldon, thank you for the quick response.

When a process instance enters a message throw event, it creates a corresponding job and waits for its completion.

This is there in the documentation. Isn’t this opposite to what I am looking for.

Secondly, I want to trigger a completely different workflow from my parent workflow. (Something similar to call activity), but call activity waits for the completion of the child workflow and only then returns to the parent.

Also, can you please advise how to call a external microservice asynchronously from a service task? For example I have a microservice which once called takes 10 seconds to complete, and only then sends a response. The response is of no use to me so I want to fire and forget the microservice.

Thank you,
Tanmai.

Hey @Tanmai_Mukku

you would publish a message via a Zeebe client in the corresponding job worker. But you could alternatively also just create another process instance via the zeebe client.

Greets
Chris

1 Like

Hi @Tanmai_Mukku
Maybe you can try switching End Event to Message End Event, and then implement a worker to send messages to trigger another process:

@Component
public class TriggerSubProcessWroker {

    @Autowired
    private ZeebeClient zeebeClient;

    @ZeebeWorker(type = "trigger-sub-process", autoComplete = true)
    public void handle() {
        zeebeClient.newPublishMessageCommand().messageName("new-instance")
                .correlationKey("") // If the correlationKey of a message is empty, it creates a new process instance and does not check if an instance is already active.
                .send()
                .join();

    }
}

Hope this helps. :slight_smile:
Zhi

4 Likes

Hi @lzgabel, @Zelldon Thank you so much. I was able to solve my problem using message throw and catch events.

2 Likes