Multiple starts events - start programmatically at a specific task

Hi,

Multiple start events are not authorized.
However how can we model 2 different starts, let’s say one start triggered by a message in a topic (through start message event) and another start triggered programmatically through a controller that receives a message?
I am thinking of calling startProcessInstanceByKey but then it will execute the whole flow and not only part of the flow (see screenshot, I want the second start to start from an intermediate step).

Is it possible?

In other words, I would need something like in Camunda where I can start programmatically at a specific task:

processEngine.getRuntimeService().createProcessInstanceByKey("twitter")
  .startBeforeActivity("service_task_publish_on_twitter")
  .setVariable("content", "Know how to circumvent the review!")
  .execute();

@yvo @filiphr @joram
Would really appreciate your help on this.

Thank you for your time.

Michel

Can’t you achieve the behavior you want with an exclusive gateway after the start that goes to the second service task in case some variable is set?

We have process instance migration for this. However, it feels like you want to model this explicitely, to me.

Also not that you can still start a message start event by calling startProcessInstanceByKey.

There’s no need to ping anyone. We all answer her on a best effort basis. Also, someone else could have the answer to your question :wink:

Thanks for your answer. Sorry for the ping… Thought (still think) you are the best :slight_smile:

@joram:
Can’t you achieve the behavior you want with an exclusive gateway after the start that goes to the second service task in case some variable is set?

I don’t think I can achieve this with exclusive gateway since there are 2 kinds of starts: either message from Kafka or programmatically when a rest endpoint is called.
I successfully used the API startProcessInstanceByKey() but as you said it goes back to the start event but I want to go back to the middle of the flow.

The flow is like this - 3 possible starts 1.a, 1.b, 1.c:

1.a Get documentID from Kafka topic
2. Call Rest to get document from documentID
3. Call service X

1.b Get documentID from an endpoint in our application (and start process programmatically?)
2. Call Rest to get document from documentID
3. Call service X

1.c Get document itself from an endpoint in our application - so no need for step 2 above (and start process programmatically?)
2. Call service X

What would be the best way to model this?

Thank you!

You see it as ‘start’, but the way I read it, it looks the same process, where certain steps are skipped with an exclusive gateway, based in data in the instance (e.g. wasStartedFromKafka or something). So not sure why it can’t be done - it’s exactly the purpose of gateways.

Thanks Joram, I ended up using the exclusive gateway with variable from the instance in order to skip unrelevant steps.