cancel
Showing results for 
Search instead for 
Did you mean: 

Increasing performance

alper
Champ in-the-making
Champ in-the-making
Hi,
I have following idea:
I tested creation of engine, and I got that the most time consuming operations are:
1).
processEngine = ProcessEngineConfiguration
            .createStandaloneInMemProcessEngineConfiguration()
            .setDatabaseSchemaUpdate(
                  ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
            .setDataSourceJndiName("java:jboss/datasources/ActivitiDS")
            .setJobExecutorActivate(true).buildProcessEngine();

2).
repositoryService.createDeployment()
            .addClasspathResource("parent.bpmn")
            .addClasspathResource("paralel.bpmn").deploy()………..<any other bpmn needed>;


Is that safe to do it once, store as static, and after that reuse these resources? According to my test yes, but I would like any confirmation from the Activiti developers, you know, to be on the safe side…

So my app has init() method that looks like:

private void init() {
      processEngine = ProcessEngineConfiguration
            .createStandaloneInMemProcessEngineConfiguration()
            .setDatabaseSchemaUpdate(
                  ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
            .setDataSourceJndiName("java:jboss/datasources/ActivitiDS")
            .setJobExecutorActivate(true).buildProcessEngine();

      runtimeService = processEngine.getRuntimeService();

      RepositoryService repositoryService = processEngine
            .getRepositoryService();
      
      repositoryService.createDeployment()
            .addClasspathResource("parent.bpmn")
            .addClasspathResource("paralel.bpmn").deploy();
   }


After that, each time I invoke the workflow, I just do it in the separate method:

runtimeService.startProcessInstanceByKey(processId, request);


Will it work ok this way, or some of those resources I mentioned in the init() I need to re-initialize each time I need the new workflow?

Thank you.
3 REPLIES 3

pkonyves
Champ in-the-making
Champ in-the-making
You only need to initialize the processengine once per application. This is also true for your deployment. Once you deploy your bpmn (process), it is in the process repository.

alper
Champ in-the-making
Champ in-the-making
What about RuntimeService?

pkonyves
Champ in-the-making
Champ in-the-making
RuntimeService uses parts of the created process engine. You can call getRuntimeService() multiple times, it doesn't affect the application performance. You can always read the code for yourself if in doubt Smiley Happy