paed01 / bpmn-engine

BPMN 2.0 execution engine. Open source javascript workflow engine.
MIT License
860 stars 166 forks source link

Is there a generic way to call ServiceTasks other than expressions? #159

Closed MaheshkumarSundaram closed 1 year ago

MaheshkumarSundaram commented 1 year ago

Hi,

Suppose, I have a process with around 10 service tasks. Each service task having its own microservice execution.

Below is my understanding of how the service tasks are called.

We use an expression in the implementation attribute

<bpmn:sendTask id="Activity_0c0fmal" name="Send Email" implementation="${environment.services.sendEmailService}" />

and define it in the services attribute of the execute

engine.execute({
    services: {
      sendEmailService() {
      }
    },
  }, (err) => {
    if (err) throw err;
  });

Do I have to do this for all 10 service tasks? or is there any other generic way to do it? Like, is there any listener or events which would only be triggered for service tasks and inside that I can check the name of the service task and call the corresponding microservice to carry out the job?

Any help would be appreciated. Thanks!

paed01 commented 1 year ago

If you inspect the arguments of the "sendEmailService" you will get the execution message, with name etc, for the specific service task. That information can be used to decide which microservice to use.