[jboss-user] [jBPM] - jBPM 4 - Deploy only if ProcessDefinition changed or new

Andrea Castangelo do-not-reply at jboss.com
Mon Nov 8 06:20:56 EST 2010

rapa [http://community.jboss.org/people/rapa] created the discussion

"jBPM 4 - Deploy only if ProcessDefinition changed or new"

To view the discussion, visit: http://community.jboss.org/message/570056#570056


I successfully integrated jBPM 4.4 with Seam 2.2, running on JBoss 4.2. 

In my overridden Jbpm class I deploy all process definitions, which are got from the components.xml 

            <value>bpm/processdefinitions/process_3.jpdl.xml</value>        </bpm:process-definitions>


The process definitions file paths (resource names) are automatically injected in the String[] processDefinitions array (see Jbpm class)

By having all file paths it is easy to deploy  the process definitions through the repository service, but I would like to avoid to deploy them each time
I restart my application server.

What I would like to do is to deploy my process definitions only if the xml file is new or has been modified since it's last deployment. The idea is simple: I just compare the last deployed process definition's xml content with the one of the current process definition.

There is a method in the repository service that allows to get the deployed process definition's xml content

repositoryService.getResourceAsStream(deploymentId, resourceName);

I see that the jbpm4_lob table is the one that contains all the required data (resource_names, deployment_ids, xml files contents), so there must be
a way to retrieve what I need.

The problem is that I looked into the jbpm 4.4 api and I don't see any way to retrieve the highest deploymentId for a given resource name. The only way is to use the process definition key or name, but I would have to map these manually somewhere to their resource name or parse the xml files, which would be very nasty and I absolutely want to avoid that.

Here is the code of my Jbpm class.

@Install(precedence = Install.APPLICATION)
public class Jbpm extends SeamComponent {
    private ProcessEngine processEngine;
    @Getter @Setter
    private String[] processDefinitions;
    public void init() {
       // ...
       // ...
     * Deploys all changed or new process definitions. 
    private void deployProcessDefinitions() {
      RepositoryService repositoryService = this.processEngine.getRepositoryService();
      for (String processDefinition : this.processDefinitions) {
           // deploy d only if new or it has changed
           if(isNewOrChanged(processDefinition)) {
              NewDeployment d = repositoryService.createDeployment()
              String newDeploymentId = d.deploy();
      private String isNewOrChanged(processDefinition) {
          // how to get deploymentId???
          InputStream is = repositoryService.getResourceAsStream(deploymentId, processDefinition);
          String xml = convertStreamToString(is);
          // ...

Anyone has a solution for this?

Thanks, cheers!

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101108/f0881f10/attachment.html 

More information about the jboss-user mailing list