Signal and Message Start Event

Hey,

I would like to start process plan with a signal or message event. Now, I’m confused about
the modeler (v.0.6), because I can fill out the following fields: Id, Name, Message (Autocompleted),
Message Name and Initiator. If I add a message, a modeler Id will be append to the
message name (e.g. Message_3kpn6jo)

The API says I can use a correlation mechanism [1]:

// correlate the message
runtimeService.createMessageCorrelation(“messageName”)
.processInstanceBusinessKey(“AB-123”)
.setVariable(“payment_type”, “creditCard”)
.correlate();

What kind of message name is represented in this code snippet? Should I use ‘Message_3kpn6jo’
or only ‘Message’ to correlate the message in my code?

Greetings,
Michael

[1] Message Events | docs.camunda.org

Hi Michael,

You have to use the message name, i.e. what you put into the “Message Name” field in the modeler. Note that you can manually change the message name to anything more meaningful.

Cheers,
Thorben

Hi Michael,

if you create a message start event with the message name My Message the modeler will create a ID for it which is something like Message_XXXXXXX.

This ID is used to reference the message in the BPMN diagram. What it will generate in the XML is a message element and a message event definition in the start event which references this message element.

<bpmn:process id="Process_1" isExecutable="false">
  <bpmn:startEvent id="StartEvent_06yvxi3">
    <bpmn:messageEventDefinition messageRef="Message_0ier3ci" />
  </bpmn:startEvent>
</bpmn:process>
<bpmn:message id="Message_0ier3ci" name="My Message" />

The reason it that multiple elements can reference this message and also multiple messages can have the same name.

To correlate the message, using the API, you always use the message name, i.e. My Message.

Does this answer your question?

Cheers,
Sebastian

Hello Sebastian, Hello Thorben,

thank you for your replies.It answered my question.
However, I`m getting now an engine expection, which is some kind of progress. :wink:

I`ve tried to implement the message with following ways:

getRuntimeService()
    .createMessageCorrelation("rfidTags")
    .correlateAll();
// second try
getRuntimeService()
    .correlateMessage("rfidTags");

Errors:

Exception while closing command context: Cannot correlate message rfidTags: 
No process definition or execution matches the parameters
// and
RuntimeException during event dispatching: Cannot correlate message rfidTags: 
No process definition or execution matches the parameters Re-throwing it.

So, the process cannot find the correlated message inside the process plan. Do I miss some configuration?

You can see my process plan in the attached picture. The XML looks like Sebastian described it.

Hi,

was your process successfully deployed? For example is the is executable flag set on the process?

For example can you find the process with:

getRepositoryService.createProcessDefinitionQuery().list();

And is there an event subscription:

getRuntimeService.createEventSubscriptionQuery().list();

Cheers,
Sebastian

isExecutable="true" in XML was set to false. Now I`m able to trigger start events with a message.

Hi Menski and MichaelM,

I am getting the same problem of message coorelation.

getRuntimeService.createEventSubscriptionQuery().list(); -------> returns zero.

My code and bomn diagram is as below : -

public class ExampleExecutionListener implements JavaDelegate {

@Override
public void execute(DelegateExecution execution) throws Exception {

	    execution.getProcessEngineServices().getRuntimeService().
	    createMessageCorrelation("FileRejected").correlateAll();

}

If this query is performed by the delegate attached to the service task, then you are hitting a limitation of the engine. Read the following thread for details: