Deployment through Java API

Hi all

According to Deployments | docs.camunda.org a deployment of a process application can be done through the Java API. Where can I find more information or an example?

I have a process application not only with a bpmn file but also with Java classes (JavaDelegate) and with HTML forms.

Thank you.

Kind regards
Micha Boller

Hi Micha,

a deployment can be created with the help of the DeploymentBuilder.
Use the RepositoryService#createDeployment Method to create a DeploymentBuilder, add the necessary resources and call DeploymentBuilder#deploy to deploy the resources.

See here for an complete example.

Greets Chris

1 Like

@Zelldon

Thank you for your answer and for the example.

How can I deploy a java file?
How to specify the path to the java file?
Or is it necessary add the class files instead of the java files?

Thank you.

Regards,
Micha Boller

Hi Micha,

if you want to deploy Java Classes you have to create a WAR archive and deploy it on our AS,
since you need the classes in the classpath to execute them. The Engine deploy method is only to deploy process definitions and other resources, which does not need to be executed.

Kind regards,
Chris

@Zelldon

Thank you for your anwser.

My use case is the following:

I use a multi-tenancy setup where every tenant has it’s own process engine.

For every tenant, I create a process engine dynamically through the Java API (https://docs.camunda.org/manual/7.6/user-guide/process-engine/process-engine-bootstrapping/#bootstrap-a-process-engine-using-the-java-api)

When the process engine is created, then I would like to deploy a process application to this newly created process engine.

I have found a code snipped where the process applications are copied from the default process engine: https://github.com/camunda/camunda-consulting/blob/master/snippets/dynamic-multi-tenancy/tenantdemo-shared-lib/src/main/java/com/camunda/demo/tenant/manager/TenantManager.java#L160-L198

Maybe this would be a possibility to deploy the WAR once to the default process engine and then copy the process application to the newly created process engine from there?

Or do you think the deployment of the WAR to the application server folder is the only possibility? But then, do I have to change the processes.xml in the WAR every time, when a new process engine is created (to modify the <process-engine>tenantName</process-engine>)?

Thank you.

Kind regards
Micha Boller

@thorben

Any idea on this? Thank you

Hi @miguelgalaxy,

The code linked above basically assumes that on the AS, a process application (WAR / EAR) is deployed with some default processes + java classes which should be shared along the tenants.
It shares those processes with a tenant by:

  • creating a new tenant specific process engine
  • creates a new deployment out of the default processes and registers this deployment with the single process application with the process engine.

This registration allows the process engine to invoke the required java classes for the processes in the deployed process application (WAR).

So you could deploy a single process application with the classes being used by the processes and register all deployments with it through the Java API like in the code you linked.
But you need to deploy a WAR with the classes being used. Dynamic deployment of classes is not supported by Camunda.
You also need to make sure that the classes of the shared process application do not hold any state as the process application is accessed by multiple tenants synchronously. Also it will be a single point of failure in your architecture. When you need to change the classes, which means redeployment of the WAR, all running process instances will stop/must be halted until it is redeployed and reregistered.
The registering / unregistering of the deployments with the process application must also be written really robust, otherwise you could end up with processes unable to process further cos it is unable to access the classes in the process application.

Yes, but you do not copy the process application but instead only create a new deployment out of the processes (BPMN etc.) + resources (not java classes) from the default process application on the newly created process engine (through Java API) and register the new deployment with the default process application

Does this help you?

Cheers,
Christian

As described above, I use a multi tenancy environment, where every tenant has its own process engine.

I want to be able to programmatically bootstrap a process engine for a new tenant and then deploy a process application to this new tenant. The process application must be available on all process engines of every tentant.

The only way I could manage this programmtically is to write a new <process-archive> section in the processes.xml in the process application war, which is located in the webapps folder of tomcat.

Hi,
I am trying to achieve something similar to what you described here.
could you help me with what changes are to be done in the process.xml file?