How to get rid of old process-definitions and prevent the engine from start instances for old versions of definitions?

374 views
Skip to first unread message

Carsten Duch

unread,
Apr 10, 2013, 4:08:23 AM4/10/13
to camunda-...@googlegroups.com
If I change the process-definition and deploy it again as a new version, I still have the old versions in my database.

If I forgot to replace the ID in my ajax call  (e.g. POST to /engine-rest/process-definition/{id}/start) it creates a new process-instance with the old process-definition which is then broken and can not be completed.

How could I get rid of the old process-definitions?
Is there a posibility to tell the engine that it should only allow new instances for the latest version of a process-definition?

thorben....@camunda.com

unread,
Apr 10, 2013, 5:58:26 AM4/10/13
to camunda-...@googlegroups.com
Hi Carsten,

with the Java API, you can start a process instance by its key (which is the id that is provided in the BPMN 2.0 xml). This will always start the latest version of the process. The REST API is not feature complete though and this particular method is not exposed yet.
However, we plan to improve it for the final 7.0.0 release and I assume that this method will be implemented by then.
The same goes for the undeployment of processes.

For now, you could look up the latest version of the process definition by using
GET /engine-rest/process-definition?key=yourProcessDefinitionKey&latest=true
This will return the latest process definition with the given key and you can use its id to start it.

Best regards,
Thorben

Carsten Duch

unread,
Apr 19, 2013, 3:44:15 AM4/19/13
to camunda-...@googlegroups.com, thorben....@camunda.com
Hi Thorben,


Am Mittwoch, 10. April 2013 11:58:26 UTC+2 schrieb thorben....@camunda.com:
For now, you could look up the latest version of the process definition by using

GET /engine-rest/process-definition?key=yourProcessDefinitionKey&latest=true
This will return the latest process definition with the given key and you can use its id to start it.

Thx, did it like you said and it works well. Just a short jquery example for others who want to experiment with the REST API:

$.ajax({
    url
: "http://localhost:8080/engine-rest/process-definition",
    type
: 'GET',
    data
: {"key":"loan-approval","latest":"true"},
    context
: document.body
   
}).done(function(data) {
       
if(typeof data[0].id != undefined){
            definitionId
= data[0].id;
            startNewProcess
(definitionId);
       
}else{
            alert
("No process-definition found in data: "+data);
       
}
   
}).error(function(data){
             console
.log("ERROR:",data);
   
});

function startNewProcess(definitionId){
    $
.ajax({
        url
: "http://localhost:8080/engine-rest/process-definition/"+definitionId+"/start",
        type
: 'POST',
        data
: JSON.stringify({"variables":{"orderId":"mySecretOrderId"}}),
        contentType
: 'application/json',
        context
: document.body
       
}
       
).done(function(data) {
            alert
("New process started.\ndata:\n\n"+JSON.stringify(data));
       
}).error(function(data){
   
             console.log("ERROR:",data);
       
});    
}
   

 

esie...@gmail.com

unread,
Apr 22, 2013, 6:41:56 PM4/22/13
to camunda-...@googlegroups.com, thorben....@camunda.com
I may have found another work-around. I accidentally compiled a process with the "Is Executable" flag set to false. When I tried to deploy it to Tomcat7, the process definition disappeared completely. Re-compiled with the flag set to true, the new version came up upon deployment.

Of course, I may be totally mis-interpreting why the old version was cleared.

Edward Siewick

esie...@gmail.com

unread,
Apr 23, 2013, 5:38:34 PM4/23/13
to camunda-...@googlegroups.com, thorben....@camunda.com, esie...@gmail.com
On Monday, April 22, 2013 6:41:56 PM UTC-4, esie...@gmail.com wrote:
...

> Of course, I may be totally mis-interpreting why the old version was cleared.

This didn't work today. Yep, I was totally misinterpreting.

Reply all
Reply to author
Forward
0 new messages