简体   繁体   中英

How to jump to the event from any process point in Camunda?

I have a BPMN process of a middle complexity with several tasks and gateways. The BPMN engine works with Spring Boot.

Now, I have the following task: if I receive a request to my endpoint, I need to trigger a special process event, no matter on which step the process is at the moment. I tried to use Signal Event, but I can't find a solution that allows me not to throw an event on a specific point, but to throw in programmatically to the specific process instance (using its execution ID).

I think I need a kind of the goto operator analogue from the C++ or @EventListener analogue from the Spring Boot events model, but not sure if Camunda provides such a functionality.

Any thoughts on it?

You can define catching events for different 'scopes'. For instance a receive message boundary event can be attached to an embedded sub processes. This way the process will be ready to receive the message for the complete duration of the embedded sub process, no matter which task it is currently in. See: https://docs.camunda.org/manual/latest/reference/bpmn20/subprocesses/embedded-subprocess/ These boundary events can be interrupting (the embedded sub process) or non-interrupting (new token fro separate branch)

Another solution is to work with event based sub processes. Those can be place inside an embedded sub process to limit them to a define scope / section of the process, or the can be place in the parent process, where they serve as a 'global' event handler. See: https://docs.camunda.org/manual/latest/reference/bpmn20/subprocesses/event-subprocess/

Once you process instance has reached a message receive state, you can send a message (or signal) to the process instance to affect its behavior. To match the message to the correct process instance out of many, you need a correlation criteron. The simplest and best solution is to give each process instance a unique business key (special process data). This business key can then be used as a parameter on the message API to correlate the message to the correct process instance. See: https://docs.camunda.org/manual/latest/reference/rest/message/post-message/ If no business key is available, a (combination of) process data can be used as correlation criterion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM