Given the following two processes in the attachments. How could I find the process instance id that threw the signal “MySignal” and started the “Called” process definition?
One way of doing this would be to add a variable containing the process instance id on the throw signal in mapping. The main issue I’m facing it that I would like to implement it using a process engine plugin. This way, I don’t have to change existing processes and all new processes will have the functionality.
Creating a variable with the current process instance id is easily done using an execution listener. Changing the throw signal variable in mapping however is not. I couldn’t find a way to add the variable containing the process instance id to the variable in mapping using an execution listener or AbstractBpmnParseListener.
Hi @Luukth, nice question but I don’t think it is possible given your constraints (do this via process engine plugin, without changing the process definition itself).
My understanding is the only way to change the runtime behaviour of a process (other than using explicit modelling, variables) is using the process modification API and this does not allow you to modify the behaviour of the currently executing element as you want (e.g. add Camunda “in” definition to a currently executing intermediate signal throw event). Also, it is not recommended for a process to mess with itself.
My understanding is that when a process instance is created it is an immutable runtime representation of the model definition at that moment (either the latest deployed version or some specific version). Even though it might be possible to access the model definition in an execution listener and change it, you are not changing the currently executing process (which was locked in at process creation time).
This is quite technical though so my confidence level on this <100% Maybe others on the forum have other ideas?
You may have to accept adding a sourceExpression camunda:in extension element to your signal definition in new process definitions and update existing definitions. Obviously this doesn’t address processes that are already in flight.
Hi, and thanks for your reply. You are indeed correct that it is currently not possible to do with an Engine Plugin.
Also, great write up on the immutability of already running process instances. Of course you don’t want to alter already running processes
What I ended up doing is a bit “hacky”. I forked the repo and made a small change on this line. With this change the receiving process(es) instances get the $$origin variable.