Is it possible for a signal to start only a subset of all processes having that signal?

Hello,
I am researching on a multitenant setup with tomcat managed StandAloneProcessEngine, where:

  • there will be a set of shared process definitions (i.e without tenant)

  • process instances are mostly started via signals, and it would be quite normal for many process definitions to have the same signal start events.

  • when sending a signal, there always is the “tenantId” variable specifying which tenant does the signaling

  • tenants start processes, which will have their tenant Id set to the instance, from the variables passed (this one I managed to do with a custom plugin)

  • (now, what causes my problem) - A tenant, may or may not customize a particular process definition Customize action is actually deploying the same process, but with a tenantId

In the case of a tenant customizing a process, I want to trigger only the customized definition, and not the shared one, when a signal got sent from that tenant

Example scenario: 2 shared process definitions

  • SharedProcess1, having start signal A
  • SharedProcess2, having start signal A
  1. whoever tenant sending a signal A, will trigger both processes, setting corresponding tenantId on them - scenario is OK

  2. Lets say, tenant1 customizes SharedProcess1, after this, in camunda we have 3 process definitions in total:

  • SharedProcess1, having start signal A
  • SharedProcess2, having start signal A
  • CustomizedProcess1, having signal A, having tenantId=tenant1

Now, if tenant1 sends signal A I want only those two processes to trigger:

  • SharedProcess2, having start signal A
  • CustomizedProcess1, having signal A, having tenantId=tenant1
    SharedProcess1, having start signal A (does not get triggered because something indicated that there is customization)

However, if tenantX, which did not customize any processes, sends the same signal A, I want to trigger the original shared processes only.

I was thinking of modifying the Customize process, and appending the tenantId, to each signalId within that process (making it tenantId#signalId), then, when someone sends a signal, the backend will actually send two signals:
a) the requested: signalId
b) another, tenant specific: tenantId#signalId

My problem is, in the described scenario above, both the shared and the customized process definitions will get executed, because of a)

Now I am thinking I need to (somehow :)) intercept the starting process, do a custom query againts camunda db, and:

  • for a shared processes that is about to start, check whether there exists the same process but with a tenantId (tenantId always we have set in variables)
  • if customized version exists - skip the execution, if not proceed with shared execution

However, I am not sure if that is at all possible. Is there a way to do that?

Thank you !
Krasimir

I came accross this example, any help with registering/amending it to query db or objects already present will be of much use to me:

Will try out registering it with camunda, although not sure if i am on the right track with it and also how to query camunda db for such information…

Use a message event instead. Messages can be used to perform the same behaviour as a signal and the message API is much more advanced than the signal API. So you can message all of your processes based on any number of filters. See the message correlation builder API.

Hi @StephenOTT

Thanks for the prompt reply!

Yes, will check it out indeed. To my understanding atm, no 2 process definitions, can have the same message Id for a start event.

The thing is, I really wanted the fanout experience, i.e i dont want to keep state, and to remember which tenant customized a process definition, and which processes actually have the requested messageId as a start event, so that I to multiply the client request (a single messageId) to multiple messageIds, that corresponds to all signals.

May be I am missing something. Is it possible with a single message to start multiple process definitions?

Btw, my backend is in dotnet, so to ask, this Interface is analogue right? (Or if you can point to some java code, that will be great!)

Thanks for the suggestion!

May I one more question, while on the topic :slight_smile: - what is the difference between CorrelationKeys and ProcessVariables, as they are both maps string:VariableValue

For ProcessVariables I know and, I already use it.

But CorrelationKeys again talks about variables to executions and I wanted to ask…

I Will write soon once I have more experince with my attempts.

based on the nuances you want to implement/how you want it to work, I would expect it is better for you to send a message to a “proxy” process which will redistribute your message to all of the desired definitions.

Example:

You have a process def that take a message start event and a process variable which is a json array of tenants. Then in that process def you have a Multi-Instance service task/send task/script task that redistributes your messages based on the array of tenants. (You don’t need to use multi-instance, you could just have a loop in your code that iterates over the tenant list):

pseudo code:

for each tenant in tenantsArray {
   execution.getProcessEngineServices()
      .getRuntimeService()
      .correlationMessageBuilder()
      .tenantId(tenant)
      .messageName(messageName)
      .correlateSingle()
}

The processes defs specific to each tenant would have messages that use message names like “MyMessage_TheTenant”.