cancel
Showing results for 
Search instead for 
Did you mean: 

Update Process Design on Runtime

erensimsek
Champ in-the-making
Champ in-the-making
Hello..

We designed a process and deployed to activiti.. The process has many recieve tasks and timer boundary events..
We started many porcess instance. We found a bug in process design and we ant to change it. We change the pocess design and deploy new process diagram to activiti again.. We update all process design with this query

update activiti.act_ge_bytearray agb
   set agb.bytes_ =
      (select agb.bytes_
          from activiti.act_ge_bytearray agb
         where agb.name_ = 'Example.bpmn20.xml'
           and agb.deployment_id_ =
               (select max(to_number(agb.deployment_id_))
                  from activiti.act_ge_bytearray agb
                 where agb.name_ = 'Example.bpmn20.xml'))
where agb.name_ = 'Example.bpmn20.xml';

At the end,  we have to restart to activiti engine for re-cache the XML content..

Is there anyway update the process designs with activiti api.?

Thank you..
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
The resources in a deployment in activiti are read-only, so they can't be altered using the API. What you COULD do, is deploy a new version of the process-definition, and run the SetProcessDefinitionVersionCmd on all the existing process-definitions, to force them using the update version:


/**
* {@link Command} that changes the process definition version of an existing
* process instance.
*
* Warning: This command will NOT perform any migration magic and simply set the
* process definition version in the database, assuming that the user knows,
* what he or she is doing.
*
* This is only useful for simple migrations. The new process definition MUST
* have the exact same activity id to make it still run.
*
* Furthermore, activities referenced by sub-executions and jobs that belong to
* the process instance MUST exist in the new process definition version.
*
* The command will fail, if there is already a {@link ProcessInstance} or
* {@link HistoricProcessInstance} using the new process definition version and
* the same business key as the {@link ProcessInstance} that is to be migrated.
*
* If the process instance is not currently waiting but actively running, then
* this would be a case for optimistic locking, meaning either the version
* update or the "real work" wins, i.e., this is a race condition.
*
* @see http://forums.activiti.org/en/viewtopic.php?t=2918
* @author Falko Menge
*/
public class SetProcessDefinitionVersionCmd implements Command<Void>, Serializable {

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

I dont want to change proc_def_id. I want to change only the all design of process..
Also I solved this problem with this code.


public void clearDeploymentCache() {
  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  DeploymentCache deploymentCache = ((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getDeploymentCache();
  Map<String, ProcessDefinitionEntity> map = deploymentCache.getProcessDefinitionCache();
  map.clear();
 
  Map<String, Object> mapKn = deploymentCache.getKnowledgeBaseCache();
  mapKn.clear();

}


Thank you for eveything.

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
Hello,
updating processes is possible and it works just fine for minor fixes.

Here is how to do it:
1: Execute SQL
<code>
– UPDATE ACT_GE_BYTEARRAY
– SET
–     BYTES_ = {put your bytes here}
– WHERE
–     ACT_GE_BYTEARRAY.DEPLOYMENT_ID_ IN (SELECT
–             DEPLOYMENT_ID_
–         FROM
–             ACT_RE_PROCDEF
–         WHERE
–             KEY_ = '{add process key here}')
–         AND ACT_GE_BYTEARRAY.NAME_ NOT LIKE '%.png%';
</code>
This will save the process content. You might want to update the sql a bit if you do not want to update all.

If you are adding programatic support you can if you want to reset cache to avoid restarting the server.
<code>
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  DeploymentManager deploymentManager = ((ProcessEngineImpl)      processEngine).getProcessEngineConfiguration().getDeploymentManager();
  deploymentManager.getKnowledgeBaseCache().clear();
  deploymentManager.getKnowledgeBaseCache().clear();
</code>
AlfrescoBlog.com


martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

use org.activiti.engine.impl.cmd.SetProcessDefinitionVersionCmd.

Regards
Martin