Hi, All!
I have event subprocess at the process level, which is started by message start event.
In some service task of main process I add execution listener on end event of this task.
Execution listener is inline javascript.
var rs = execution.getProcessEngineServices().getRuntimeService();
rs.messageEventReceived("my-message", execution.getProcessInstanceId());
and get runtime error when service task is finished:
Cannot submit task form 5811: Execution with id '5804' does not have a subscription to a message event with name 'my-message': eventSubscriptions is empty
after that I tried in that execution listener to query event subscriptions and save some parameters to process variables, like that
var rs = execution.getProcessEngineServices().getRuntimeService();
var es = rs.createEventSubscriptionQuery().eventName("my-message").singleResult();
execution.setVariable("esaid", es.getActivityId());
execution.setVariable("even",es.getEventName());
and it works fine, process vars have expected values.
Same behaviour for 7.4 and 7.5.
Any help will be very appreciated…
diagram.bpmn (5.6 KB)
@ArtyomKosykh could you use a boundary Message Event attached to your Script Task (in your example BPMN file) ?
@StephenOTT I didn’t exactly understand you. Are you suggesting to attach boundary event to my Script Task? But i want to throw event/send message, and attached boundary event are only for catching/receiving purposes, right?
All my (maybe crazy) idea was to start some event subprocess after every activity by throwing message from execution listeners. This subprocess may have some validation of process state, may be even User Task as in my example.
Could you provide a little more details on your use case / scenario? I am not sure I understood, and my Message Event suggestion may have been from a misunderstanding.
Why do you want to start a sub-process after every activity?
I implemented some integration process with only service tasks, this process is started by timer event (cycle).
My idea sound like this: if this process started by user (initiator variable is not empty) to create some user tasks after some service tasks mostly for testing and debugging purposes.
Make sense?
P.S. Possibly i totally misunderstood message throw and catching events in Camunda. Will try to switch to Java delegates in day or two. May be something wrong with my javascript.
As a simple fix, could you just use JavaScript that calls a web service without using a Service task? You could embed this script in your execution listener?
I assume if the service tasks are being used for testing/debugging, you are basically sending log-type of data to a server. ?
I got some points, and yes, i was wrong with my approach.
@StephenOTT, you didn’t get what i meant, with all my fault.
Interesting fact: just change in my example diagram.bpmn message start event in subprocess to non-interrupting and got way another exception:
Cannot create concurrent execution for ConcurrentExecution
As i understand this puzzle…
Execution listeners run within same transaction as activity which they’re attached.
And subprocess is starting new execution which cannot be done from active transaction of the same origin/parent execution. Something like that. Or maybe I need to sleep
May be some experts in Camunda Process Engine will correct my guess…
@ArtyomKosykh how about you move your sub-process into a separate BPMN file, and use a BusinessKey to associate the main BPMN with the ‘sub-process’ bpmn. And instead of using a message start event, you can just use a Blank start event in your sub-process bpmn file.
@StephenOTT If you mean to use Call Activity for my use case, It will definitely work.
I just stumbled upon this exactly problem with execution listener, now i think i am ok with call activity
Hi @ArtyomKosykh,
I assume that execution.getProcessInstanceId()
gets you ID of of a main process and not subprocess, could you try to lookup subprocess explicitly by key?
Cheers,
Askar
Hi @aakhmerov. I could not get subprocess ID, because there is not any subprocesses yet, i tried start subprocess by sending message.
If I trigger event (send message) by REST API for example, everything will work, i get my subprocess instance (in interrupting or non-interrupting way, depends on type of message start event).