Deploying a process programatically

385 views
Skip to first unread message

P

unread,
Aug 1, 2014, 8:26:07 AM8/1/14
to camunda-...@googlegroups.com
Hi,

I'm reviewing Camunda for integrating it in our environment, but I'm a bit stuck early on in the process.

I've included the required jars on the classpath (not getting any classNotFound errors), and created a processEngine:
ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration().buildProcessEngine();

Next I create a modelInstance and deploy it:
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess('ExampleProcess')
.name("Example process")
.startEvent()
.userTask()
.name("Some work to do")
.endEvent()
.done();

File file = java.io.File.createTempFile("bpmn-model-api-", ".bpmn");
Bpmn.writeModelToFile(file, modelInstance);

processEngine.getRepositoryService().createDeployment()
.name('test-2')
.addInputStream("FluentTest", new java.io.FileInputStream(file))
//.addModelInstance("FluentTest", modelInstance) //Also tried this variant, but same issue
.deploy()

After running this code, which raises no errors, I'm logging the following:
log.debug(processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId('ExampleProcess').list())
log.debug(processEngine.getRepositoryService().createDeploymentQuery().deploymentName('test-2').list())

Which gives me:
DEBUG []
DEBUG [DeploymentEntity[id=1, name=test-2, resources=null, deploymentTime=Fri Aug 01 13:06:31 CEST 2014, validatingSchema=true, isNew=false]]

So, my conclusion is that the proces "ExampleProcess" in my deployment is not available. Where am I going wrong?

Hope someone can share some insight,

Regards,

Paul

Daniel Meyer

unread,
Aug 1, 2014, 8:51:02 AM8/1/14
to camunda-...@googlegroups.com, pgba...@gmail.com
Hi Paul,

two things:

  //.addModelInstance("FluentTest", modelInstance) //Also tried this variant, but same issue
should be changed to 
  .addModelInstance("FluentTest.bpmn", modelInstance)

And this

   log.debug(processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId('ExampleProcess').list())

should be changed to

   log.debug(processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey('ExampleProcess').list())


Does this help you?

Daniel

pgba...@gmail.com

unread,
Aug 1, 2014, 9:05:07 AM8/1/14
to camunda-...@googlegroups.com, pgba...@gmail.com
Excellent! Now it works.

In my attempts I had also tried "processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey('ExampleProcess').list()", but that didn't return anything either.

The main issue was the missing ".bpmn" in the resource name. Didn't find that anywhere in the docs.

Tnx for your quick response
Reply all
Reply to author
Forward
0 new messages