The main question is about static fields and singleton instances (for configs, etc.) - are instances of one process running in different threads, as usual servlet requests?
If look deeper - do different @ProcessApplication
run in one JVM and will see the same singletons? I don't think so. I know exactly that their classes don't see each other and can have equal names (because of different classLoaders?)
Haven't found any meaningful info on these important themes about Camunda, will appreciate your answers.
A Java Delegate is a simple Java class that implements the Camunda JavaDelegate interface.
By default, Camunda comes with an embedded database called H2, which works pretty decently within a Java environment with relatively small memory footprint.
Use the Camunda Modeler to add a service task after the user task. To do so, select the activity shape (rectangle) and drag it onto a sequence flow (see screenshot). Name it Process Request. Change the activity type to Service Task by clicking on it and using the wrench button.
Camunda's Workflow Engine executes processes that are defined in Business Process Model and Notation (BPMN), the global standard for process modeling. With BPMN, you can automate your most complex business processes using an easy-to-adopt visual modeling language.
I had this same question for one of our scenario while back, and read their Javadoc as mentioned here for a servlet container. Extracting Javadoc,
Invocation Semantics
When the {@link #execute(java.util.concurrent.Callable)} method is invoked, the servlet process application modifies the context classloader of the current Thread to the classloader that loaded the application-provided subclass of this class. This allows,
- the process engine to resolve {@link JavaDelegate} implementations using the classloader of the process application
This pretty much explain everything you want to know, since the behavior is very similar to how a web container operates. If you want to know how other container implementations behaves, you can check the respective Javadocs of classes in this package.
To answer your question:
Yes. Thread-safety is required for the shared-resources accessed by JavaDelegate
in the same process application. According to the documentation (see below) they create a new instance of delegate each time a task is going to be executed.
Note!
Each time a delegation class referencing activity is executed, a separate instance of this class will be created. This means that each time an activity is executed there will be used another instance of the class to call execute(DelegateExecution).
Therefore, at any time there can be many delegate instances actively running due to the multiple invocation of Process Definitions
. So, if they are accessing a shared resource, then they need to be synchronized (thread-safe), because, that shared resources (static or singleton) is local to the process application and loaded by respective application classloader according to above Invocation Semantics Javadoc.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With