Two places for process definition identifier on deployment?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2012 05:24 AM
I am wondering why it is necessary to provide the process definition two times during deployment. The first time I need to give it to the the method call:
repositoryService.createDeployment().addInputStream(identifier, inputStream).deploy();
and the second time I need to specify it inside the id element of the process definition.Now I have the scenario where a user uploads workflow definitions to a server. The server executes the workflows based on these definitions. The problem is, that the user can not know which identifiers where used by other users to upload worklfows, so I need to assign identifiers on the server side. This is only possible by exchanging the identifier in the process definition, which requires me to parse the XML on the server side. That is quite ugly, since I had hoped that the identifier provided to the "addInputStream" method would be sufficient to call access the workflow definition later on.
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2012 10:27 AM
I don't understand your question, why is it necessary to provide the process definition two times?
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2012 11:22 AM
So lets say the process is deployed initially and runs for several days on some server. After that time someone changes the process definition on a client and loads the changed definition (new XML File) file to the server. From that time on all processes should be started with the new definition instead of the old and the old one should be removed from the server.
To be more concrete: We have a server that carries out complex information extraction algorithms on some business documents. From time to time we try different algorithms. The task of the workflow steering those algorithms always stays the same. We need to exchange the old workflow definition with a new one every time we reconfigure which algorithms are used to achieve our task. This needs to be done using some REST API on our server. So what I need to achieve is the ability to upload a bpmn process definition to the server via the REST interface. As soon as the server recieves the new process definition it should start new calls to the information extraction algorithms with the new process definition.
I already solved the problem with the process identifier which is defined in two places by parsing the XML description and changing the identifier within the XML description to the one the server uses internally. However when I try to exchange the process defintions I always get the message: "org.activiti.engine.ActivitiException: no processes deployed with key 'extraction'".
Some minimalistic code:
String processIdentifier = "extraction";
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
// Load the original process definition from hard disk.
String processDefinition1 = FileUtils.readFileToString("processDefinition1.bpmn20.xml");
// deploy original process definition. The first problem occurs here since I can not be sure that the id attribute of the process element in "processDefinition1.bpmn20.xml" is equal to "processIdentifier".
repositoryService.createDeployment().addString(processIdentifier, processDefinition1).deploy();
// maybe run the process once.
RuntimeService runtimeService = processEngine.getRuntimeService();
runtimeService.startProcessInstanceByKey(processIdentifier);
// Load the changed process definition from hard disk.
String processDefinition2 = FileUtils.readFileToString("processDefinition2.bpmn20.xml");
// exchange the old process definition with the new one.
String deploymentIdentifier = repositoryService.createProcessDefinitionQuery().processDefinitionId(processIdentifier).list().get(0).getId();
repositoryService.deleteDeployment(deploymentIdentifier);
repositoryService.createDeployment().addString(processIdentifier,processDefinition2).deploy();
// now the changed process definition should run but I get: org.activiti.engine.ActivitiException: no processes deployed with key 'extraction'
runtimeService.startProcessInstanceByKey(processIdentifier);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2013 10:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013 12:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013 05:31 AM
- deploy process for testing(test_process_id)
- create test process instance and test it, test instances must not shown in product processes list.
- if process is pass
- deploy the same process in product mode(product_process_id)
Can avtiviti achieve this case without change the process id of process-definintion?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013 11:10 AM
You can set the category to 'development' for the test ones and 'production' for the 'real ones'. However, the id (key) must indeed be unique accross the system.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013 09:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013 03:41 AM

As joram says, you'll have different keys for the processes, but have another mechanism to indicate they belong together.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013 09:04 AM
But.. when I deploy a process with category, the category is always refer to targetNamespace of the bpmn definition, not the category I specified, what's wrong with me?
Here is th e code snippet:
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneInMemProcessEngineConfiguration()
.buildProcessEngine();
RepositoryService repositoryService = processEngine
.getRepositoryService();
repositoryService.createDeployment().category("category")
.addClasspathResource("bookorder.bpmn20.xml").deploy();
assertEquals(0, repositoryService.createProcessDefinitionQuery()
.processDefinitionCategory("category").list().size());
assertEquals(1, repositoryService.createProcessDefinitionQuery()
.processDefinitionCategory("http://www.bpmnwithactiviti.org").list().size());
