cancel
Showing results for 
Search instead for 
Did you mean: 

External process definition version

mmaker1234
Champ in-the-making
Champ in-the-making
Hello,

We need to track the execution of process instances and often we need to relate the track to the process definition. As we have no access to the Activiti (production) DB we need to relate these tracks (execution history) to the source file of the process definition. Unfortunately one and the same process definition file can have different deployment (Activiti) version on the different (development, test, production) servers. That is why we need to store our own (external for Activiti) version/reference of the process definition.

We tried to:
- manually add attribute "exporterVersion" to <definitions> tag but Activiti Diagram Editor removes it on save (BTW references to http://www.omg.org/spec/BPMN/20100524/… are not correct - currently there is no such path on the OMG server. An available path is http://www.omg.org/spec/BPMN/20100501/… but there is no MODEL, only BPMN20, BPMNDI, DC, DI, and Semantic)
- use the <process>…<documentation> tag but due to http://jira.codehaus.org/browse/ACT-1020 we can not read the reference.

We also cannot use the business key to store the process definition file version due to http://jira.codehaus.org/browse/ACT-1230. But even if the problem in ACT-1230 does not exist, we think that the business key is not the appropriate place to keep file versions. Additionally, the business key have to be set run-time and our business logic is isolated from the Activiti internals.

Are there any other ideas how to cope with this problem?

Here is an example of our problem:
I created five versions of a process definition called MyProcDef:
MyProcDef v.1
MyProcDef v.2
MyProcDef v.3
MyProcDef v.4
MyProcDef v.5

On the development server all versions were deployed:
MyProcDef:1:1234 [v.1]
MyProcDef:2:1234 [v.2]
MyProcDef:3:1234 [v.3]
MyProcDef:4:1234 [v.4]
MyProcDef:5:1234 [v.5]

On the test server only few of them were deployed:
MyProcDef:1:2345 [v.2]
MyProcDef:2:2345 [v.5]

On the production server only one was deployed:
MyProcDef:1:3456 [v.5]

When I investigate a reported problem and receive a process history I can not tell instance of which version of my process definition (file) was executed because there is no relation between the Activiti deployment version (MyProcDef:?:…) and the version of the process definition source file.
7 REPLIES 7

frederikherema1
Star Contributor
Star Contributor
About ACT-1020, see comment + current workaround. Seems to me that bending the "description" to store your process-versioning is a valid solution. Another thing that is available is the "category" of the process-definition, this is also exposed in the API.

You could leverage that, set the value in the BPMN using the targetNameSpace attribute on root element:


<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition"
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="myProcDef/v3">

mmaker1234
Champ in-the-making
Champ in-the-making
Hello Frederik,

Thank you for your answer - I will try the workaround.

I'm afraid that targetNamespace is not appropriate because our version contains spaces (I suppose you could recognize the following "version": $Revision: 1.4 $ 🙂 ) That is why we are still interested in a dedicated field/tag in the .BPMN file for such a piece of information.

mmaker1234
Champ in-the-making
Champ in-the-making
Hello again,

Probably I'm doing something wrong or there's a bug in Activiti.

Here is (part of) my process definition:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="RunReportRequests">
  <process id="RunReportRequests_ImmediateExecution" name="RunReportRequests_ImmediateExecution">
    <documentation>$Revision: 1.4 $</documentation>
    <startEvent id="startevent1" name="Start"></startEvent>


I'm trying to retrieve the process definition (and its "external" version):

      ProcessEngine processEngine = WfEngineManager.getProcessEngineConnection("MyWFengine);
      HistoricProcessInstance processInfo = processEngine.getHistoryService().createHistoricDetailQuery().processInstanceId( processInstanceId ).singleResult();
      ReadOnlyProcessDefinition processDefinition = (ReadOnlyProcessDefinition ) processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId( processInfo.getProcessDefinitionId() ).singleResult();
      LOG.info( "ProcessDefinition ID = " + processDefinition.getId() + "; Name = " + processDefinition.getName() + "; Description (version) = " + "; Description (version) = " );

And the result is
ProcessDefinition ID = RunReportRequests_ImmediateExecution:16:12604; Name = RunReportRequests_ImmediateExecution; Description (version) = null
instead of
ProcessDefinition ID = RunReportRequests_ImmediateExecution:16:12604; Name = RunReportRequests_ImmediateExecution; Description (version) = $Revision: 1.4 $

What I'm doing wrong?

frederikherema1
Star Contributor
Star Contributor
Try debugging your code and see what "properties"  are present in the ReadonlyProcessDefinition you obtain (contains a map with all parsed properties). Check what the value for key "documentation" is… Sometimes it helps actually looking into our source code, than you see how the documentation is parsed and ends up in the ProcessDefinition.

mmaker1234
Champ in-the-making
Champ in-the-making
Debugging my application together with Activiti, I reached the point
org.activiti.engine.impl.db.DbSqlSession.selectList(String statement, Object parameter, Page page)
where the call to
loadedObjects = sqlSession.selectList(statement, parameter); //Call to org.apache.ibatis.session.SqlSessionreturned my process definition with null properties collection, which explains why the "documentation" property is also null.

Any advice how to make Activiti to load the process definition properties?

frederikherema1
Star Contributor
Star Contributor
Did you get the ReadonlyProcessDefinition using RepositoryServiceIMPL.getDeployedProcessDefinition()? the properties are NOT in the DB, but are parsed. So by looking at your previous post (and the selectList) I presume you're just using the ProcessDefinitionQuery…

mmaker1234
Champ in-the-making
Champ in-the-making
Hello Frederik,

Thank you for the feedback!

The replacement of       ReadOnlyProcessDefinition processDefinition = (ReadOnlyProcessDefinition ) processEngine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId( processInfo.getProcessDefinitionId() ).singleResult();
with
      ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl)repositoryService).getDeployedProcessDefinition( processInfo.getProcessDefinitionId() );
did the work! 🙂