How do I send a message from one process to another?


#1

This is probably a dumb question… :slight_smile:

We have a process currently that when it finishes, sends a signal that another process needs to start, operating on the same basic set of variables. This is pretty straightforward as we can just use a Signal End Event.

However, from my beginners understanding of BPMN (and my general knowledge of messaging patterns), I had the impression that a Message would be a better way to do this - we don’t want to broadcast a Signal to any needed listeners, we want to message a single known process that should pick up the flow of work at that point. (i.e. this seems like it should be point-to-point not publish/subscribe?)

However, I can’t seem to get even a basic example of this to work - if I have a process foo.bpmn with a Message End Event, with a message named message_bar - and I have a process bar.bpmn with a Message Start Event, with a message also named message_bar - it just doesn’t work.

I have a feeling I’m missing something fundamental here. All the docs seem to have messages within a single bpmn process, on different participants/pools - is it possible to do this to another process entirely?

Also Message End Events don’t have a lot of documentation - they seem to just say “he Message End Event has the same behavior as a Service Task.” - does that mean we need a Java implementation???

Please enlighten me! Or should I just stick to signals? (I’m not even sure if messages will let me share variables between the processes)


#2

You have to execute the message through a expression, java delegate, or script.

here is a simple example to get you started using a expression:

${execution.getProcessEngineServices().getRuntimeService().createMessageCorrelation("message_bar").correlateWithResult()}

see: https://docs.camunda.org/javadoc/camunda-bpm-platform/7.8/org/camunda/bpm/engine/runtime/MessageCorrelationBuilder.html for more API options.