Understand command pattern


A question to broaden my understanding of the process engine. The architecture guide tells me that it is using a command pattern to send commands/requests to the process engine.

What is unclear to me is how the result of that command is retrieved in order to return that result to the user (e.g. when performing a request to the REST api.

Further, in a clustered environment. How is this issue tackled there?

Kind Regards and thanks in advance,


Hi @bart,

I think this is a misundestanding. Camunda uses the command pattern under the hood of its Java API, i.e. a command’s result is the return value of the API method. That is independent of the environment Camunda runs in.

To which section of the docs are you referring? Perhaps I can put that statement into context then.


The documentation I was referring to is the following: https://docs.camunda.org/manual/7.4/introduction/architecture/#process-engine-architecture

From the image it shows here, it seems to me, it is a ‘fire-and-forget’ kind of command pattern. There is no result returned.

In light of one of my older questions. If a process modification is sent to the engine it could fail (e.g. LockException). So I don’t seem to grasp where my client/caller gets notified of this exception so it can be reported back to the user of the REST api (probably by means of a 500 result code).



The image is misleading in that respect. It does not describe if/what is returned by the API. As the command pattern is an internal concept (if we replaced its functionality with something else, most users would not notice), I personally wouldn’t have included it in that picture. The Java API (equivalent to Public API in the picture) does have return values.

If a request fails due to optimistic locking, the Java API throws an instance of OptimisticLockingException. That can be caught by the calling code and in the Camunda’s REST API, it is transformed into a HTTP 500 response.