Is it possible to configure an external nodejs microservice to run on any lifecycle events?
Not right now - although @Nele did create a quite interesting workaround for this that she might be able to share with you.
Well in one Project where we needed a Listener as an external Taks worker, we used a Scrip in the task listener to basically set a variable. Then we used in BPMN an event subprocess with a non interrupting conditional event that was triggered once the variable was set. This was followed by a service task which we implemented as external worker and was the main listener… something similar like this example.bpmn (4.2 KB)
Of course your model might get a little bit more unstructured… Depending on how many different Listeners you need…
Hi @Nele - I had attended your unconference session yesterday!
So I was trying to model my use case where I need to assign the task to the user in my application, as well as to send a notification for the user. So what I understand is that I need to have a reference to the task ID so that the user can complete the task on my app.
When the execution reaches this step, I need to trigger an external task. For that I have assigned the variable as below,
I have modeled the sub process as below,
What is happening is that the variable gets set correctly, but the sub process is not executing. So I tried opening cockpit and changed this
userTaskStart variable from true to false, and then again to true. When that happened it sent execution to the sub process, and it exited!
Is there something I am missing?
- I need the sub process to execute when the task is created - this will run business logic to sync task id to application
- I need the execution to resume at the task
the last time we used such a pattern was not on an usertask. So I rebuild the case and I get the same problem. I don’t think that this behavior is intended… at least it confuses me… I’ll try to get more insights and let you know if I can get more information… or we both wait if someone shows up, who can explain it here ^^
I cannot explain at the moment why it is not working at the task create event, but if you use this expression on a EventListener ( event-type: start) then it works as expected.
@McAlm thanks for the input. I did not exactly understand where to make the change, I have tried each of the following and it is not working,
I am getting errors using the REST API for the last two settings.
@McAlm yes that worked for me and I am able to access the sub process task details in my nodejs worker.
Am I right in thinking that I should make a REST call in my worker to
engine-rest/task?processInstanceId=... to get the original user task details, and perform my application fuctionality?
Yes. You can use whether a GET call
or a POST request (which is slightly more powerful)
to filter for the task.
Be aware that you have to complete not only the user task but also the external task, otherwise your process instance will not finish.
You can even simplify it more by adding a create listener that adds the task id to the process variables. This way your worker can filter directly for that specific task. See this example:
UserTaskTriggersEventSubProcess.bpmn (4.5 KB)