Send an error signal

Hi guys,

I’ve created a workflow with a subprocess and a boundary event on it (see the screenshot below)

I’m trying to send programmatically an error signal without success.

        mRuntimeService.signalEventReceived(pSignalName, pExecutionId);
            .createSignalEvent(pSignalName)
            .executionId(pExecutionId)
            .setVariables(lTransientVariables)
            .send();

Camunda says

 Execution '1503' has not subscribed to a signal event with name 'annullata'. is empty

Do you have any suggestions?
Thank you,
aGO!

Hello @tavolate ,

the error event exists to catch an error that happens inside the subprocess. If you want to cancel the subprocess, you should use a message boundary event.
To use the error correctly, one of the activities inside your process should throw it.

I hope this helps

Jonathan

Thank you @jonathan.lukas.
Can I throw it programmatically?

Hello @tavolate ,

yes. Inside a JavaDelegate, it is possible to throw a BpmnError containing code, message and cause.
This will then be mapped to a error event inside your process.

https://camunda.com/best-practices/dealing-with-problems-and-exceptions/#_throwing_and_handling_strong_bpmn_errors_strong

This article might be helpful.

Jonathan

OK but outside a Delegate, perhaps by Runtime service?

Hello @tavolate ,

it is possible in the task service. This is intended to be used by user tasks and external tasks.

hope this helps

Jonathan

Thank you @jonathan.lukas but I need to throw it from a restful endpoint.
I have all information needed (execution id, business key …)

Hello @tavolate ,

if I got you right you are waiting for a message that contains information about an error that happened? This is exactly the use case of a message catch event.

The error event would mean that during a service call (either snychron or external) or a human task, an error comes up that needs to be handled in a certain way.

I can also provide some example models later if you want.

Jonathan

Hello @jonathan.lukas,

thank you for your support.

Maybe it’s better if I tell you what I’m trying to do.

I have a workflow with a subprocess inside it.
I would like to be able to cancel the subprocess at any time by an external message.
When I cancel the subprocess the parent process must go into a “Terminate End Event” (“Annulla” into my screenshot).

According to that, I used an error event because it stops the process, contrary to messages.

I hope now it’s more clear.

Hello @tavolate ,

if you use an interrupting message boundary event, also this will stop the subprocess.

I think this is exactly the behaviour you want to achieve.

Jonathan

Thank you @jonathan.lukas, I will try!

Hello @jonathan.lukas,

I modified the workflow according to your suggestion (see screenshot below)

But when I reach the “Message End Event” (red circle) the activity is interrupted and the sequence flow doesn’t continue through the “Message boundary event” (red circle) but it is going out the normal flow (green circle).

Unfortunately, messages in BPMN have a rule by which a process cannot send a message to itself.
If you replace them with an error event or an escalation event it’ll work.

1 Like

@tavolate , we had a misunderstanding then. Instead of using the message end event inside the subprocess, I would have expected you to send a message directly to the boundary event from outside. I am sorry for this.

I need both.

Hence, I can use en error event (like before) for inside event and a message event from outside for the other scenario.

Right?

Yes, that is a way of solving this.

1 Like

it works!
Thank you!

1 Like