External implementation of Message End Event

Hi,

I’m new to Camunda implementation. I’m running through Camunda training Niall Deehan. However I’m looking for External implementation of Message End Event. Tutorial shows java implementation but for my project it needs external implementation.

Request an lead to this.

Thanks in advance.

Hello @Bhavesh_G ,

you can use the implementation type “External” as usual. What you will probably do is then sending a message towards the REST API of the Engine and then complete the external task.

https://docs.camunda.org/manual/latest/reference/rest/message/post-message/

Hope this helps

Jonathan

Hi @jonathan.lukas ,

Thank you for reply. Are u saying it to be done in following steps:

  1. Create message end event with external implementation.
  2. Provide topic name.
  3. Write a java class method which will subscribe to topic in point 2
  4. from method mentioned in point 3, send message using REST API. This message will be caught by message catch event or message start event.

Thank you.

1 Like

Hello @Bhavesh_G ,

yes, this is described very accurate :slight_smile:

Let me know whether it works.

Jonathan

1 Like

Hi @jonathan.lukas ,

I can get a control in external handler by subscribing to a topic. However to send a message from handler method, it needs a business key which is not available in org.camunda.bpm.client.task.ExternalTaskHandler. I’m using camunda 7.15.0 version.

Request your input.

Thanks in advance.

Hello @Bhavesh_G ,

when handling an external task, you will work with an instance of org.camunda.bpm.client.task.ExternalTask which contains the method getBusinessKey().
Also, when sending a message via REST API, you can provide a business key there.

Hope this helps

Jonathan

Hi @jonathan.lukas ,

Method org.camunda.bpm.client.task.impl.ExternalTaskImpl.getBusinessKey() returns null. While checking on internet I found Jira https://jira.camunda.com/browse/CAM-8952 and forum link External task, business key related to this issue. As business key is coming null sending message is not possible.

Thank you.
Bhavesh G

Hi @jonathan.lukas @Niall

Its also a good idea to give overall picture of use case I’m trying achieve. The use case is there is main process, which is calling a sub-process. outcome from sub-process can be 3, first is success response, second is error response and third is timeout. There can be more that one type of possible errors and those needs to be process separately by main process. Can you please suggest a suitable model for the same.

Thank you.
Bhavesh G

Hello @Bhavesh_G ,

this made me curious, so I tried out. This is the log output of the ExternalTask object:

ExternalTaskImpl [activityId=Activity_0u3bzrj, activityInstanceId=Activity_0u3bzrj:b5d4cfc0-e571-11eb-a54c-22bdaaf58870, businessKey=exampleKey, errorDetails=null, errorMessage=null, executionId=b5d4cfbf-e571-11eb-a54c-22bdaaf58870, id=b5d4cfc1-e571-11eb-a54c-22bdaaf58870, lockExpirationTime=15 Jul 2021, 15:44:47, priority=0, processDefinitionId=new_key_2:1:95743cb1-e571-11eb-a54c-22bdaaf58870, processDefinitionKey=new_key_2, processDefinitionVersionTag=null, processInstanceId=b5d4a8ad-e571-11eb-a54c-22bdaaf58870, receivedVariableMap={}, retries=null, tenantId=lukasjo, topicName=automatic, variables={}, workerId=Jonathans-MBP.fritz.box8797e962-9a92-47ca-9373-a813a7dfabbd]

As you can see, the business key is correctly transferred to the client.

Please make sure the business key is set at the time you fetch and lock the task.

Jonathan

Hello @Bhavesh_G ,

to answer this question, I would suggest a (schematic) process like this:

Hope I understood you well.

Jonathan

Thank you @jonathan.lukas I will defiantly try a model suggested and also will post the code and output for ExternalTaskImpl business key scenario

1 Like

Hi @jonathan.lukas ,

Surprisingly I’m still not able to get business key in call activity. Attached are BPM diagram for the same. Am I doing anything wrong here? Request your attention

Below are logs
Jul 19, 2021 6:11:37 PM com.camunda.servicetask.impl.ServiceTaskImpl lambda$0
INFO: serviceTask1 business key::exampleKey
Jul 19, 2021 6:11:37 PM com.camunda.servicetask.impl.ServiceTaskImpl lambda$1
INFO: serviceTask2 business key::exampleKey
Jul 19, 2021 6:11:37 PM com.camunda.servicetask.impl.ServiceTaskImpl lambda$2
INFO: serviceTask3 business key::null
Jul 19, 2021 6:11:37 PM com.camunda.servicetask.impl.ServiceTaskImpl lambda$2
INFO: externalTask:::ExternalTaskImpl [activityId=Activity_1dkmv5x, activityInstanceId=Activity_1dkmv5x:a8a4e174-e88e-11eb-b5f1-00090ffe0001, businessKey=null, errorDetails=null, errorMessage=null, executionId=a8a4e173-e88e-11eb-b5f1-00090ffe0001, id=a8a4e175-e88e-11eb-b5f1-00090ffe0001, lockExpirationTime=Jul 19, 2021 6:11:38 PM, priority=0, processDefinitionId=otherProcess:1:ceb4ad7b-e87f-11eb-b5f1-00090ffe0001, processDefinitionKey=otherProcess, processDefinitionVersionTag=null, processInstanceId=a8a4e171-e88e-11eb-b5f1-00090ffe0001, receivedVariableMap={}, retries=null, tenantId=null, topicName=serviceTask3, variables={}, workerId=IXEDLAPMUB004de802f2a-acb1-4a5b-8708-9d6bff11173c]

.variable_passing_demo.bpmn (4.3 KB) other_process.bpmn (2.3 KB)

Hello @Bhavesh_G ,

in the Call Activity, there is the possibility to pass the Business Key from parent process to child process:

This should resolve your issue.

Jonathan

2 Likes

Hi @jonathan.lukas ,

Thank you so much for prompt response. Appreciate your support on this matter. Its working.

1 Like