nitram509/lib-bpmn-engine

QUESTION: How to execute a process in async way

magicLian opened this issue · 3 comments

	instance, err := bpmnEngine.CreateAndRunInstance(process.ProcessKey, variables)

This function CreateAndRunInstance seems like a sync one, actually i need an async run function instead. So am i do wrong or something?

Hi,

indeed, the concept of the engine is a synchronous one.
There is no support for parallel / asynch operations present.
That said, you could simply work with goroutines and so having the execution running parallel to your main work task.
Please, keep in mind, that multi-threading always comes with a price, means you must ensure accessing the engine is synchronized since the engine itself is not secure/safe when multiple threads read&write to it.

Regards
Martin

Hi Martin,
Thanks for your reply. Got it.

Hi Martin, Thanks for your reply. Got it.

You're welcome.
PS: depending on your use case, you mind find user tasks helpful, to do asynch stuff, without goroutines.
See https://nitram509.github.io/lib-bpmn-engine/implementation-task-handlers/#service-tasks-vs-user-tasks