nitram509 / lib-bpmn-engine

A BPMN engine, meant to be embedded in Go applications with minimal hurdles, and a pleasant developer experience using it. This approach can increase transparency for non-developers.
https://nitram509.github.io/lib-bpmn-engine/
MIT License
274 stars 70 forks source link

QUESTION: How to execute a process in async way #136

Closed magicLian closed 1 year ago

magicLian commented 1 year ago
    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?

nitram509 commented 1 year ago

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

magicLian commented 1 year ago

Hi Martin, Thanks for your reply. Got it.

nitram509 commented 1 year ago

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