cancel
Showing results for 
Search instead for 
Did you mean: 

Deployment

luisalves00
Champ in-the-making
Champ in-the-making
Hello,

Trying to integrate Activiti engine on a webapp.

Init the engine - ok
Deployment - getting new version every time I start the server even tough the process is the same.

do you check if the process was modified? or just with Spring?

Spring integration also has a special feature for deploying resources. In the process engine configuration, you can specify a set of resources. When the process engine is created, all those resources will be scanned and deployed. There is filtering in place that prevents duplicate deployments. Only when the resources actually have changed, will new deployments be deployed to the Activiti DB. This makes sense in a lot of use case, where the Spring container is rebooted often (eg testing).

Here is the code…


public final class ContextListener
        implements ServletContextListener {

    private static final Logger logger = Logger.getLogger(ContextListener.class);

    public void contextInitialized(ServletContextEvent event) {
        //context = event.getServletContext();
        try {
            ProcessEngines.init();
            Deployment deployment = ProcessEngines.getDefaultProcessEngine().getRepositoryService().createDeployment().addClasspathResource("org/me/gae/activiti/bpmn/simpleApprove.bpmn20.xml").enableDuplicateFiltering().name("simpleApprove").deploy();
            logger.log(Priority.INFO,
                    "Deployment ID:" + deployment.getId() + " - " + deployment.getName() + " @"  + deployment.getDeploymentTime());
        } catch (Exception e) {
            logger.log(Priority.FATAL, "Couldn't initialize Activiti Engine ", e);
        }
….

got 8 version so far.

best regards,
la00
8 REPLIES 8

jbarrez
Star Contributor
Star Contributor
I'm not quite following? You are trying to use a Spring feature in a programmatic way?

luisalves00
Champ in-the-making
Champ in-the-making
yes…

but seems that is only a spring feature!
I'm not using Spring.

Need to implement the feature myself.

pseudo-code
Store the workflow xml on DB
use http://xmlunit.sourceforge.net/
if diferent load
else process is alrey deployed.

but it would be nice if this feature was supported outside Spring.

frederikherema1
Star Contributor
Star Contributor
Hi,

When using "enableDuplicateFiltering" on the deploymentBuilder, duplicate deployments will be ignored. Make sure deployment name is the same, the same resources are included (same name and same bytes):

This happens when deploying an already existing deployment (using API and Spring)

public Deployment execute(CommandContext commandContext) {
    DeploymentEntity deployment = deploymentBuilder.getDeployment();

    deployment.setDeploymentTime(ClockUtil.getCurrentTime());

    if ( deploymentBuilder.isDuplicateFilterEnabled() ) {
      DeploymentEntity existingDeployment = Context
        .getCommandContext()
        .getDeploymentManager()
        .findLatestDeploymentByName(deployment.getName());
     
      if ( (existingDeployment!=null)
           && !deploymentsDiffer(deployment, existingDeployment)) {
        return existingDeployment;
      }
    }

luisalves00
Champ in-the-making
Champ in-the-making
Thanks frederikheremans,

That was what I was expecting when using .enableDuplicateFiltering() (more info on the javadocs would be nice) but I think it didn't work. I'll do more testing later…

Now I have the confirmation that enableDuplicateFiltering() do what I need it to do.

keep the good work.

best regards,
la00

luisalves00
Champ in-the-making
Champ in-the-making
Getting new deployments all the time

Code:


try {
            ProcessEngines.init();
            Deployment deployment = ProcessEngines.getDefaultProcessEngine().getRepositoryService().createDeployment().enableDuplicateFiltering().addClasspathResource("org/me/gae/activiti/bpmn/simpleApprove.bpmn20.xml").name("simpleApprove").deploy();
            logger.log(Priority.INFO,
                    "Deployment ID:" + deployment.getId() + " - " + deployment.getName() + " @" + deployment.getDeploymentTime());
        } catch (Exception e) {
            logger.log(Priority.FATAL, "Couldn't initialize Activiti Engine ", e);
        }

Log:


INFO: ProcessEngine default created
14/Abr/2011 13:57:03 org.activiti.engine.ProcessEngines initProcessEnginFromResource
INFO: initialised process engine default
14/Abr/2011 13:57:08 org.activiti.engine.impl.bpmn.deployer.BpmnDeployer deploy
INFO: Processing resource org/me/gae/activiti/bpmn/simpleApprove.bpmn20.xml
14/Abr/2011 13:57:09 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XMLSchema currently not supported as typeLanguage
14/Abr/2011 13:57:09 org.activiti.engine.impl.bpmn.parser.BpmnParse parseDefinitionsAttributes
INFO: XPath currently not supported as expressionLanguage
13:57:39,493  INFO ContextListener:43 - Deployment ID:1301 - simpleApprove @Thu Apr 14 13:57:07 WEST 2011


Inspecting the deployment -> isNew is set to true.

st_patriick
Champ in-the-making
Champ in-the-making
Two things:

1) I think you need to deploy the png image of the process diagram with the BPMN file. If you do not, the image is generated automatically and added to the deployment (but after it is compared with the one in the database). So the next time you would be comparing a deployment just with the BPMN file with one containing both BPMN and PNG and they would not be the same.

2) The deployment command uses a DB query that orders the deployments the wrong way. There is a bug this in JIRA: http://jira.codehaus.org/browse/ACT-736. You would have to change the query definition in the MyBatis mapping file (see the JIRA issue for more info).

luisalves00
Champ in-the-making
Champ in-the-making
Added the png image like this:

try {
            ProcessEngines.init();
            Deployment deployment = ProcessEngines.getDefaultProcessEngine().getRepositoryService().createDeployment().enableDuplicateFiltering().addClasspathResource("org/me/gae/activiti/bpmn/simpleApprove.bpmn20.xml").addClasspathResource("org/me/gae/activiti/bpmn/simpleApprove.png").name("simpleApprove").deploy();
            logger.log(Priority.INFO,
                    "Deployment ID:" + deployment.getId() + " - " + deployment.getName() + " @" + deployment.getDeploymentTime());
        } catch (Exception e) {
            logger.log(Priority.FATAL, "Couldn't initialize Activiti Engine ", e);
        }

and changed the query as reported here: http://jira.codehaus.org/browse/ACT-736?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-t... (opensource is great)

going to do some testing…and then I'll tell you if I was successful.

tks st_patriick

luisalves00
Champ in-the-making
Champ in-the-making
think it works…

5:22:56,582  INFO ContextListener:43 - Deployment ID:2701 - simpleApprove @Fri Apr 15 13:57:34 BST 2011

Deployment ID:2701 <- remains after restart