cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass a BusinessKey to a SignalStartEvent process definition?

jwestra
Champ in-the-making
Champ in-the-making
I'd like to kick off any number of processes that are subscribed to a signal name and started therefore by a SignalStartEvent. 

I'd also like these process instances to have a "business key".

However, there is no API to pass a business key in the numerous RuntimeService.signalEventReceived() overloads.

I am thinking about this approach:
1.) Listening to ProcessInstance ENTITY_INITIALIZED event
2.) Pulling out a process variable of my own called "my.business.key" from the signal's Map<String,Object>
3.) Call RuntimeService.updateBusinessKey() with the value of the "my.business.key" process var.

How are people solving this problem?
2 REPLIES 2

jwestra
Champ in-the-making
Champ in-the-making
Well, my first inclination was close, but not perfect.!  Big "swing and a miss" on the ENTITY_INITIALIZED event.  But, here's how I was able to get a business key into my process that is started by a signal…
=======================================================================

1. I created a 'reserved' process variable name, let's say "SIGNALSTARTEVENT_BUSINESSKEY"

2. Registered Process ExecutionListener for the "start" event on the process definition.

In the ExecutionListener.notify() method I do this:

3.  I always use RuntimeService APIs to signalEventReceived(…….) overload API that takes the Map<String,Object> to include process variables.

Once the process is started by the signal,

4. In the ExecutionListener.notify(), if a process variable exists, I call RuntimeService.updateBusinessKey() with the value of SIGNALSTARTEVENT_BUSINESSKEY.

5. And, then I call "execution.removeVariable(SIGNALSTARTEVENT_BUSINESSKEY)" to clean it out since it is no longer needed.

Hope this helps others solve this problem!

Jason


jbarrez
Star Contributor
Star Contributor
Thanks for posting this, Using an execution listener with the map payload is indeed what I would do too.