Catch event template dynamic message name

Hello, I have a Catch Event template that I will share below, my problem is that when I use this template directly, I can dynamically create the message name with the entered parameters, and the process progresses without errors.

{
“$schema”: “https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json”,
“name”: “Service Task Result Event”,
“id”: “ServiceTaskResultEvent”,
“version”: 1,
“description”: “”,
“category”: {
“id”: “connectors”,
“name”: “Connectors”
},
“appliesTo”: [
“bpmn:IntermediateCatchEvent”
],
“elementType”: {
“value”: “bpmn:IntermediateCatchEvent”,
“eventDefinition”: “bpmn:MessageEventDefinition”
},
“groups”: [
{
“id”: “properties”,
“label”: “Properties”
}
],
“properties”: [
{
“label”: “Element id”,
“description”: “Kontrol edilecek service task element id’si.”,
“group”: “properties”,
“type”: “String”,
“value”: “”,
“binding”: {
“type”: “zeebe:input”,
“name”: “elementId”
},
“constraints”: {
“notEmpty”: true
}
},
{
“type”: “Hidden”,
“value”: “= elementId+ "-success"”,
“binding”: {
“type”: “bpmn:Message#property”,
“name”: “name”
},
“condition”: {
“property”: “isSuccess”,
“equals”: “success”
}
},
{
“type”: “Hidden”,
“value”: “= elementId+ "-fail"”,
“binding”: {
“type”: “bpmn:Message#property”,
“name”: “name”
},
“condition”: {
“property”: “isSuccess”,
“equals”: “fail”
}
},
{
“id”: “isSuccess”,
“label”: “Processing result”,
“group”: “properties”,
“description”: “İşlem başarılı/başarısız koşulu.”,
“value”: “success”,
“type”: “Dropdown”,
“choices”: [
{
“name”: “Success”,
“value”: “success”
},
{
“name”: “Fail”,
“value”: “fail”
}
],
“binding”: {
“type”: “zeebe:input”,
“name”: “isSuccess”
}
},
{
“id”: “resultExpression”,
“label”: “Result data map”,
“group”: “properties”,
“description”: “Gelen veriyi variableslara mapleme için, örn: {"deger1" : response.body.deger1}.”,
“feel”: “optional”,
“binding”: {
“name”: “resultExpression”,
“type”: “zeebe:property”
},
“type”: “Text”
},
{
“type”: “Hidden”,
“value”: “= WorkflowProcessInstanceId”,
“binding”: {
“type”: “bpmn:Message#zeebe:subscription#property”,
“name”: “correlationKey”
}
}
]
}
image

2

But when I use it after an event based gateway (this is what I really need, service task writes the relevant task to a message queue, another application reads the message and reports whether it is successful or unsuccessful, and the window listens to it and continues the process), it gives an error. Because it cannot access the elementId and isSuccess variables that I use as zeebe:input, the reason is that event based does not wait directly on message events, so these variables defined locally cannot be accessed.

3

Expected result of the expression ’ elementId+ “-fail”’ to be ‘STRING’, but was ‘NULL’. The evaluation reported the following warnings:
[NO_VARIABLE_FOUND] No variable found with name ‘elementId’
[INVALID_TYPE] Can’t add ‘“-fail”’ to ‘null’

reminder: this situation does not occur in parallel gateway because it goes directly to the message event step and can see local inputs.

What kind of solution could there be her

Can I go back a step?

Why are you using dynamic message names in the first place? You should be able to accomplish this with static message names, and using the correlation keys to get it routed to the correct instance.

We match the process with an id held in the internal system and use this id as the correlation key, since the message is published globally, we guarantee that it is unique, the service leaves a job to the queue via task workers, the consumer application that does this job tells another queue whether it is successful or not, then the consumer that reads this leaves a message to the Zeebe client and Camunda, Camunda listens to this message with a structure like the one below. The problem here is that the event based gateway cannot access local inputs because it does not wait directly on the catch event. (processing result and element id)

4
5

If the message was:

TO: ProcessBusinessKey
Subject: Outcome
Body: Fail

Then you wouldn’t need to use dynamic messages.

You haven’t been able to articulate a clear driving reason to use dynamic messages. Sometimes things don’t work simply because they aren’t designed to work the way you want them to.
Since it seems like the system doesn’t work the way you want it to, consider taking a step back and determine if there’s a nother way to solve it.

So do you have any suggestions for this structure? We need to learn whether another application that does the job asynchronously has finished successfully, and we should do this through a single application that communicates with camunda. Our only problem here is the template we created to facilitate process preparation, otherwise we have no problem using the message catch event directly. The main subject of my question is about templates.

As you correctly pointed out, when you use an event-based gateway, the tokens don’t go to the message-receive, so the variables don’t work.

I was suggesting that you restructure so that you are not using multiple-dynamic messages when you can use a single-static message, which eliminates the variable access issue with the templates.

But… you might get a different answer if you put a support ticket in (this is a user discussion forum, not an official support channel, and I don’t work for Camunda)

1 Like

thanks @GotnOGuts