Search code examples
activitibpmn

Set the process id for the execution of a process in activit


is it possicble to set the processID on my own in activiti?

I would need to monitor it with a different software, so i need the ID of the started process befor the process ist started.

try{
                processId = runtimeService.startProcessInstanceByKey(jobsModuleName.toString(), processVariables).getId();
            }catch (Exception e){
                LOG.error(e, "No Processdefinition found with this Identifier");
            }

this is the call for starting the process know. i get back the id from the process, but i want to set the processID before starting the process.


Solution

  • The Process Instance ID is generated using either the DbIdGenerator or StrongUuidGenerator classes (you select the configuration on your engine configuration class). There is nothing to stop you creating a custom ID generator but keep in mind it must generate a unique ID across any and all instances.

    While I don't know your exact use case, I would probably not change the ID, rather I would use the Business Key instead. The Business Key is intended to be injected and act as user configurable metadata. Instances and tasks can be searched by business key in exactly the same was as by ID as they are both unique columns in the backing table.

    You can read about the business key here:

    http://www.activiti.org/userguide/#_additional_features

    Hope this helps, Greg