Spring Boot Activiti - auto deploy *.bpm20.xml files

cancel
Showing results for 
Search instead for 
Did you mean: 
sayantan_sinha
Active Member

Spring Boot Activiti - auto deploy *.bpm20.xml files

Jump to solution

I have setup Activiti using Spring Boot integration. Per the default behavior, the *.bpm20.xml files needs to be under src/main/resources/processes for the Activiti engine to deploy when the spring boot app is run.

Is there a way to allow Activiti to auto deploy whenever I put in a new process xml file? This actually means in order to achieve this, I need to externalize the location for the *.bpm20.xml files so that the spring boot jar does not need to be repackaged every time I add a new file. 

1 Solution

Accepted Solutions
jearles
Established Member II

Re: Spring Boot Activiti - auto deploy *.bpm20.xml files

Jump to solution

Sayantan,

I believe this should be possible, but it would take custom modification to Activiti Community in order to reach a functioning result. There are several resources 'listening' to file/folder changes in Java - feel free to go with the one you prefer. Then there are a several relevant files that I would look into within Activiti:

  • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/ActivitiProperties.java - This file contains the getters and setters for the pathing that pulls the process resources in.
  • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/AbstractProcessEngineAutoConfiguration.java - This file is where the SpringProcessEngineConfiguration is established, which references the next file:
  • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/AbstractProcessEngineConfiguration.java - There is a method (discoverProcessDefinitionResources) inside of this file that combines the location prefix with the file suffix in order to make a list of auto-deployment files. After the engine is configure it's used within:
    • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/JpaProcessEngineAutoConfiguration.java
    • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/DataSourceProcessEngineAutoConfiguration.java

This was just an initial effort to find how and where these elements are being configured. Within this path of classes, you should be able to establish a listener that would either be a part of your ProcessEngine (so you'd have to add additional functionality to the ProcessEngine) or create a listener that would update/replace the ProcessEngine in the current context. I believe the first option is going to be least likely to cause you problems - but take a look at pros and cons as you pursue this, for sure.

Hope this helps get you started Smiley Happy
-JEarles

View solution in original post

5 Replies
jearles
Established Member II

Re: Spring Boot Activiti - auto deploy *.bpm20.xml files

Jump to solution

Sayantan,

I believe this should be possible, but it would take custom modification to Activiti Community in order to reach a functioning result. There are several resources 'listening' to file/folder changes in Java - feel free to go with the one you prefer. Then there are a several relevant files that I would look into within Activiti:

  • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/ActivitiProperties.java - This file contains the getters and setters for the pathing that pulls the process resources in.
  • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/AbstractProcessEngineAutoConfiguration.java - This file is where the SpringProcessEngineConfiguration is established, which references the next file:
  • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/AbstractProcessEngineConfiguration.java - There is a method (discoverProcessDefinitionResources) inside of this file that combines the location prefix with the file suffix in order to make a list of auto-deployment files. After the engine is configure it's used within:
    • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/JpaProcessEngineAutoConfiguration.java
    • /activiti-spring-boot-starter-basic/src/main/java/org/activiti/spring/boot/DataSourceProcessEngineAutoConfiguration.java

This was just an initial effort to find how and where these elements are being configured. Within this path of classes, you should be able to establish a listener that would either be a part of your ProcessEngine (so you'd have to add additional functionality to the ProcessEngine) or create a listener that would update/replace the ProcessEngine in the current context. I believe the first option is going to be least likely to cause you problems - but take a look at pros and cons as you pursue this, for sure.

Hope this helps get you started Smiley Happy
-JEarles

sayantan_sinha
Active Member

Re: Spring Boot Activiti - auto deploy *.bpm20.xml files

Jump to solution

Thanks a lot for this insight. I will get started on this and see if I can build something custom. Is there any roadmap to make this a configurable item, like property based?

jearles
Established Member II

Re: Spring Boot Activiti - auto deploy *.bpm20.xml files

Jump to solution

Sayantan,

It's certainly possible to make elements of this configurable options through properties - like, modifying the location that Activiti is looking for files, the frequency/method it's checking for new files, and so on. And it again, would certainly be possible to make this configurable through the UI. The biggest difficulty you're going to run into is that the ProcessEngine is configured during the initial boot, and these constitute changes to the ProcessEngine - so you'll need to make sure those changes are being propagated correctly, or that the ProcessEngine is being replaced when you create a new one.

I wouldn't really say I have a roadmap for a feature like this, and I haven't found any resources on other Activit users developing it - so it looks like you're the first Smiley Happy

-JEarles

sayantan_sinha
Active Member

Re: Spring Boot Activiti - auto deploy *.bpm20.xml files

Jump to solution

I think this should be a very standard feature and it would immensely help during development rather in production. Can this be implemented in a future version? I do understand the complexity involved, but with spring boot you probably could leverage a couple of things here:

  1. provide a property to externalize process file location in conjunction with src/main/resources/processes
  2. leverage Spring Boot's @RefreshScope to achieve this, if may be not with path then certainly with file names as a separate property configuration

One thing, to keep in mind here is that with @RefreshScope we can leverage to trigger the deploy with /refresh rather than a true auto deploy.

amirelhajjam
Member II

Re: Spring Boot Activiti - auto deploy *.bpm20.xml files

Jump to solution

Hey everyOne,

i have the same need to do a hot deploy with activiti, did you find anything that can help me do it 


Thanks !