Rest Api based workflow - Http-Connector and handeling errors

Hello,

I am thinking about using Camunda while focusing on its Rest API capabilities mostly in order to avoid the usage of Java.

For a starting “demo” project i built a pretty simple workflow which relays on the http-connector component. I found enough info and examples to make it work.

So at the moment i got something like 6-7 synchronic external tasks and i also added an event boundy for handeling bad http responses ( 404, 500 ,400 etc ). Every one of those tasks has an event boundy and at the moment all of the event boundries are leading to one additional external task which is meant for the “error handeling”.

I got two questions,

  1. So far i failed to figure out how to pass extra details to that task. I couldnt find any examples that covered that.
    In the examples i only seen a simple if case of something like

if ( statusCode == 400 ) throw BPMN Error ( “errorCode” )

which then triggers the event boundy and follows up into another task ( in my case the “error handeling” external task). But how can i pass or retrive extra details? For a starter even simple things such as an error message which i can then work with in my “error handeling” external task?

Or maybe there is a better way to accomplish that?

  1. I wanted to ask if such a workflow ( one which focuses on sending http requests to different services ) is something that you advice for or against? ( the Java option is not going to work for us ).

Thank you in advance!

i am a heavy user of http-connector, and found some limitations with it. So ended up with this solution: Replacing Http-Connector with Jsoup usage. To date it works super well.

What do you mean by “pass extra details to that task”?
You use variables to pass data between tasks. You can further modify these variables using Input/Output configurations at the task level.

1 Like

Thank you alot!
I will have a serious look on that tomorrow.

Also,
What do you mean by “using Input/Output configurations at the task level.”

Do you mean the ‘setVariable’ and ‘getVariable’ commands which can be use inside the script section of a task?
Or is there maybe a different / better way?

Yes.

1 Like

Look at something like https://medium.com/@stephenrussett/throwing-bpmn-errors-with-javascript-in-camunda-c678f4b7d9ff

Hey @lvgi, how did it go with your project? I’m trying to build a similiar architectural approach as well.

care to share your working examples?

@chrysalis what are you trying to build that is not provided with http-connector and usage such as scripting and Jsoup?

I choose a different approach.
I used the following example as a base to build from.

Instead of using http-connector on the bpmn tasks themselves I got a C# service(one or more) which keeps on sending fetchAndLock http requests to the camunda engine to retrieve topic names and then via reflection executes c# code.
The reason why i choose this approach is because i felt that i got a lot more control over the process and it seem to fit much better with the requirements i am having.
But in either case it is still to early to tell how well it will work out .

2 Likes

Did you choose #C since it’s your go-to language?

I’m trying an external service as well using Node, and i’ve read some challenges on external services, particularly with idempotency, how were you able to handle this on your application?

Care to share a highlevel explanation?

I thought about node as well but i choose C# because indeed i got more experience with it over node and also because the above example gave me a very good starting point for C#.

In terms of idempotency it is still a work in progress for me so it might be to early to comment on that, but basically for now my approach is to drop any bad process and record the error for possible future handling. There are different types of errors although which needs to be covered in different ways but it might be more specific for my case.

Also to reduce issues with transactions I am constantly trying to reduce those to minimal tasks which remain with bare bone actions (like a simple save to a DB) while must of the logic happens before or after as needed.

1 Like