Assuming I have a very simple process, where I get a customer’s age, income and number of children as start data and would like to use these fields to calculate their life expectancy. Should I use a service task (with what parameters) or is this rather a connection task (like a REST service)?
My assumptions:
For a Service task
Input: age, income, numberOfChildren
Output: lifeExpectancy
But how do I actually connect the service? When I add a service task to my model and select a template (e.g., REST), the task type changes. What do I have to enter as Task definition (type/retries), Header, Extension properties and so on?
Sorry, if this obvious or stupid - I’m no techie… I’d much appreciate any help!
… and I mean in general terms, of course - I don’t expect you to give concrete URLs for my fictive example!
Hi @NickGabben.
This really depends on the setup of your system. Do you already have a REST service that can be called with these parameters? Then you could use the REST connector to just call that directly from the engine.
On the other hand if you have a spring boot application with an embedded camunda engine, then you could use a delegate expression as implementation for your service task and directly access your variables in the service.
Or you could use the external task pattern to let some worker do the job, which can be a better approach if the job takes a little bit longer:
Here is the link to the architecture overview of how you can run the camunda platform 7.
In general, high-level terms (details can expose the exceptions to the rules…), a “Connector” task is a specialized, re-usable service task. Often the Connector has been built to allow some parameters to be changed on each call (which could include the URL)
It is 100% possible to replicate the REST connector (and in fact some forum members have done so) using a service task – sometimes to add additional logging, or add additional features.
I remember there being issues with the C7 REST connector and HTTP response codes (I can’t remember exactly since I stick mostly to modeling), but if you’re not really ready to start working on code, it might meet your needs to show what can be done.
I did play around a little and for me as kind of a noobie, a REST call seems easier and I’ve encountered those in previous engagements. A REST service you can pretty much define as you need it in Modeller, right? Whereas for a service task you need more background development? Is that a fair high-level description?
What do you mean by that? The REST service still has to be developed and needs to consume your inputs and return your expected results.
There are low code (or even no code) solutions where you can model a lot more, but in the end you still need some code, if you really want to calculate or do something useful.
For Camunda it would really depend on your usage scenario. Is there already a REST service you just want to call? Then you could use the connector.
But this also has some drawbacks in regards to testing and staging, which you have to be aware of.
Sorry, I did not mean to insult you, but just to clarify the context.
For Camunda 7 I would personally prefer to use a delegate execution rather than a connector.
Mostly due to better testability and staging.
But if you don’t have that much experience in development, the connector is probably a viable solution.
If you already have an endpoint to perform this service, and you just want to call it passing the data… so that it does the processing and returns a response, you can use the http-connector.
You will need to configure a service task like I did in the example below:
Here in below, I’m considering that you have the data you need each one in a process variable within camunda, and you want to pass this data to your API.
and we are creating an object (in this case a payload)…
and we are assembling the payload to fetch the data from your process variables and pass the values to your API…