You do not need to code Java in order to develop on Camunda BPM. This Showcase demonstrates how to use Camunda BPM in combination with the .NET-Platform. All code examples are given in C#.
A class library named "Camunda Client" is contained, which can serve as a basis for your own projects using Camunda. It abstracts the details of remote communication with the Camunda BPM Platform.
- Make sure you have a Java Runtime on your machine (or download and install Java).
- Download the Community Edition of Camunda as Tomcat distribution (or any other distribution if you have a preference). Alternatively you might prefer to try out the enterprise edition.
- Unzip the distribution and start it using the batch file provided in the root folder.
- Clone or download the project provided in this GitHub repository and open it in Visual Studio
- Run the project of choice:
- Insurance Application: Simple application process for a fictive car insruance. Implements the example shown in the Camunda Poster. Contains all models in German and English.
- InsuranceApplicationCamundaTasklist: Using the Camunda Tasklist and HTML forms
- InsuranceApplicationWpfTasklist: Using a WPF Tasklist and WPF pages for task details
- SimpleCalculationProcess: Very easy process to get started
- Urlaubsantrag: Very easy vacation request process in German to get started
- Insurance Application: Simple application process for a fictive car insruance. Implements the example shown in the Camunda Poster. Contains all models in German and English.
A process application might be a simple console application in C#. The following screenshot shows the content of the InsuranceApplicationCamundaTasklist console appplication:
It consists of:
-
Models (BPMN, CMMN or DMN): You can add models to your application. If you configure them to be "embedded resources" they can be scanned by the "Camunda Client", which deployes them to the Camunda Engine via REST-API.
-
External Task Workers: Service Tasks and Send Tasks can be implemented using External Tasks. This means, you only enter a so called "Topic"-Name in the BPMN model and query tasks for External Workers via REST API. The workers can be fully implememted in C#.
-
Task Forms (HTML): If you want to use the Camunda Tasklist you can leverage [Embedded Task Forms] (https://docs.camunda.org/manual/7.5/user-guide/task-forms/#embedded-task-forms) - HTML Snippets which are shown for certain User Tasks. The HTML forms can be added to the application. If configured as "embedded resource" they can be scanned by the "Camunda Client", which deployes them to the Camunda Engine via REST-API.
If you do not want to use the Camunda Tasklist, you can also write your own
- Custom Tasklist: This showcase contains a complete Tasklist written in WPF. Now you can add WPF-Pages to be shown for certain User Tasks.
When using the Camunda Client a Worker is as easy as CalculationWorker:
[ExternalTaskTopic("calculate")]
[ExternalTaskVariableRequirements("x", "y")]
class CalculationAdapter : IExternalTaskAdapter
{
public void Execute(ExternalTask externalTask, ref Dictionary<string, object> resultVariables)
{
long x = Convert.ToInt64(externalTask.variables["x"].value);
long y = Convert.ToInt64(externalTask.variables["y"].value);
long result = x + y;
resultVariables.Add("result", result);
}
}
You can use embeded forms (e.g. Sample HTML Form) which are deployed within the Camunda Engine. Therefor add the form key:
camunda:formKey="embedded:deployment:CamundaModels.DE.decide.html"
The Class Library Camunda Client is not meant to be a re-usable, stable component. It is meant to serve as example and can be a starting point for your own code. Feel free to copy and modify the code, as it is released under Apache License you can do what you want with the code.
See SimpleCalculationProcess Example´ on how-to start and stop the Camunda Client.
During Startup the client:
- Scans the classpath for Models (BPMN, CMMN and DMN) as well as HTML-Files. The files must be tagged as "embedded resource" to be part of the classpath! All found files are deployed to the Camunda Engine via REST-API.
- Scans the classpath for classes having the ExternalTaskWorker attribute set. For all workers found a thread is started, which polls Camunda regurlary for new work and executes it if found.
Stopping the Camunda Client means to stop and dispose all running Threads.
You can also write a complete customized tasklist, e.g. as WPF application. In the sample tasklist we provide here, we can load WPF pages as task forms for User Task. Instead of referencing HTML forms we now point to the class name (including namespace) in BPMN now:
camunda:formKey="InsuranceApplicationWpfTasklist.TaskForms.EN.DecideAboutApplication"