Couple a service task with a simple microservice in Java

Hi!

So, me and some friends are currently playing around with the Camunda modeler. We have managed to deploy a simple process as a Spring boot application which basically starts with a user task and moves to a service task and then ends.

In another repository we have developed a microservice which takes a request which has a customerId and returns a name as a response.

The thing we want to achieve is basically coupling the actual microservice with the service task so that the customerId that you send in through the Camunda cockpit gets sent as a request to the microservice which in turn returns the name as a response back in the Camunda process.

We have looked a little bit on the Java delegate interface but we are not sure that it is the right thing to do. The microservice works when we send a request with Postman.

Thanks!

@simonrisberg, your assumption was correct. There are two approaches. Either from Java delegate on service task you can invoke the rest api or can invoke using external-task-pattern

Also refer this video link:

Docs:

Thank you for the link.

We will check it out!

So, I still don’t really understand how the coupling works. The microservice that we have created currently exists on http://localhost:8080/getperson while the Camunda engine exists on http://localhost:7000.

This is currently how the code looks like. What am I missing? Is it possible to have a Skype call one day?

Your service task in Camunda can call the microservice either through scripting, java delegate, or via an external task. When the process arrives at the task it will run the code to contact your microservice and from there you can do what you want with the response. A typical use-case would be to set a process variable to contain the returned values.

So, we have managed to couple our microservices with our service tasks. However, right now Camunda does not save the history of the different paths that the processes have taken. Does someone here have any experience in how to implement this?

FYI: We went with the Delegate pattern.

Hi @simonrisberg,

how did you setup your Camunda engine?

The default configuration of the history level is FULL. https://docs.camunda.org/manual/7.11/user-guide/process-engine/history/#set-the-history-level

The History view in the Cockpit is an enterprise feature: https://docs.camunda.org/manual/7.11/webapps/cockpit/bpmn/process-history-views/

If you don’t want to use the enterprise version and run your engine with a history level greater than NONE, you can query the history either by REST Api (https://docs.camunda.org/manual/7.11/reference/rest/history/) or in the database directly.

Hope this helps, Ingo