Using Camunda with "normal" Front-End Web Application

So this is either going to be a really stupid question (new to Camunda) or, I am hoping, there are some examples or best practices someone can point me to - since I’ve struck out on massive Googling!

I am evaluating Camunda as the BPM engine for a massive web app. The app has all the normal stuff you’d expect… users move from one page to another, hit re-load or back button, some pages auto-refresh, there are lots of graphs and dashboards that update independently while the page is open. The app is very rich in style, graphics, blah blah.

A lot (but not all) of what the App does is basic workflow/BPM type work. We’d like to replace the home-brew workflow since it’s getting pretty nasty to manage!

What I am trying to do is use Rest calls from the front-end (AngularJS) to start and stop Camunda processes AND get data back from Camunda into the AngularJS code (so it can update dashboards, for example).

All I have found on the web is how to embed Angular (forms) in Camunda. With respect to forms, for example, I could not find a way to get the data from a Camunda task back to Angular front-end, when the front-end code posted a call to start a Camunda process. For example, a login screen, where I could call a Camunda login verification process and send a “Yes” or “No” to the front-end.

The question is:

  1. Am I approaching this the wrong way? (entirely possible)
  2. If so, are there any “best practices” or “design patterns” out there to address this type of use case?

Thank you, one and all, for any guidance.

Bob

1 Like

Hello @bob,

Here are some APIs you can call from your app:

Start a process instance: https://docs.camunda.org/manual/7.9/reference/rest/process-definition/post-start-process-instance/
Get or set varibales: https://docs.camunda.org/manual/7.9/reference/rest/process-instance/variables/
Delete the process instance: https://docs.camunda.org/manual/7.9/reference/rest/process-instance/delete/

With the history services you can query for the state of the running (and completed) process instances: https://docs.camunda.org/manual/7.9/reference/rest/history/

Call this services as you will call other services from AngularJS.

Hope this helps, Ingo

Thank you for your suggestions @Ingo_Richtsmeier. I have played with the first two calls you suggested. But I may have missed something. I will go back and review and double-check.

I had not considered the history service. That is an awesome suggestion. I will try that next.

Thank you for your thoughtful reply.

Best,

Bob

I too have a similar use case but with react application. Like @bob has mentioned about login use case, say I started the login process, but it has to go through several validation service tasks and then finally it has made an entry in audit table and then return the response as success or failure. If I have BPMN process, will the rest API to start the login process, can it get a response in synchronous fashion after completing all tasks?

Hi @pradeep, you could set withVariablesInReturn to true in the request body: https://docs.camunda.org/manual/7.9/reference/rest/process-definition/post-start-process-instance/#starting-a-process-instance-with-variables-in-return

Hope this helps, Ingo

1 Like

Hi @Ingo_Richtsmeier and @pradeep… I think I have found a way around this problem, as well as what I think may be a bunch of bugs!

I was able to set a variable in the process and send it back to the calling rest client. What I had to do was to create/pass the variable in the client, then pass that variable from the client in the body of the REST call. The return with variables has to be set to true. I was then able to set it in the engine and get back the new value in the response body of the REST call.

I also experimented with Input/Output variables using the modeler. I think there are a bunch of bugs here. When I set those variables, the modeler generates

    <camunda:inputOutput>
      <camunda:inputParameter name="input1" />
      <camunda:outputParameter name="output1" />
    </camunda:inputOutput>

As you can see, there are no type information in the XML, even though I specified Text in the modeler.

When I look at the instance variables, I see the type as NULL. This can’t be right or usable.

The work-aorund of setting a variable in the rest client is probably OK (although a horrible solution) for most cases. I didn’t want to use the history call because that would mean making at least two calls for each client/front-end operation. That maybe OK for a toy application, or one that only has a few users, but it clearly is a problem for any real world application. I am not sure if I understand Camunda well-enough to say this but, if this in fact is the case, it would clearly indicate, at least to me, that Camunda is not suitable for commercial-grade web or mobile apps.

I have not given up on Camunda yet, although I am probably leaning that way. I have not found any indication that the Community version of Camunda is being used in any real world applications. Perhaps the paid version has less bugs in it?

But even so, the clunkiness of getting a variable value back from the engine is certainly a huge negative for Camunda - unless I am still not getting something!

I would love to hear from the Camunda folks, or other community members on the above assessment.

Best,

Bob

Modeler: 1.16.2
Server: 7.9 Community

Hi @bob,

have alook at the docs how input-output mapping works:https://docs.camunda.org/manual/7.9/user-guide/process-engine/variables/#input-output-variable-mapping.

I think you are missing the value to input. Mostly I use an expression for this, sometimes a constant value.

Hope this helps, Ingo

Thanks @Ingo_Richtsmeier This works for me

Hello,

excuse me for chiming in with my very uneducated opinion. I have very basic understanding of camunda but have worked with other BPMN engines. Hence my reply is based on my general understanding of BPM.

@bob,what you seem to want is to start a process when user clicks on a link and get a response (with some value) synchronously. This contradicts to my understanding of what processes are for since processes are asynchronous entities in the first place. You get most from the platform if you let them go instead of trying to control them from outside using some APIs. IMO one should use processes if either of the following criteria is met:

  1. Long running scenario with some waiting points (waiting for external events and resuming then)
  2. Parallel threads of execution with join points (easily implemented in BPMN)
  3. Ability to see the instance and inspect each step and the data in it using the built in monitoring tools

Of the poins above, only the 3 applies to your case, if I’m not mistaken. If it is the reason for you to bring a competely new technology and product into your solution, then of course go on. Otherwise I’d use some other solutioin (usual web controllers or the like).

Hi @fml2. Thanks for taking time to respond.

I do NOT require (or want) a synchronous response. That aside, the issue is not HOW the response is produced (i.e. synchronous or asynchronous). The issues is WHAT the response sends back. The problem I ran into was how to get a variable/value generated by the engine and send that back to the REST client. The simplest example is a binary true/false value in response to a pair of user/password values, passed on to a Camunda process. While as my post mentioned, I did manage to kludge my way around that, the solution was just that - a kludge.

Thanks, just the same, for your kind reply.

:–)

Bob