cancel
Showing results for 
Search instead for 
Did you mean: 

sequential PROC_INST_ID_

sudhi123
Champ in-the-making
Champ in-the-making
Hi,

  Does somebody know how the PROC_INST_ID is generated? Is there a sequence in the database?
It seems so, that the activiti process engine has one global number which grows with every instance of an element (process, task, gateway, …).
My application users are familiar with numbers between 1 and 99999  talk about the corresponding instance, but the PROC_INST_ID grows very fast over the 5 digits edge and then it is to hard to remember the number for shouting it over the corridor or use it in a telephone conversation.
How can I implement my own number mechanism in the activiti engine?

Thanks for the help in advance.
5 REPLIES 5

sudhi123
Champ in-the-making
Champ in-the-making
any takers?

sathish1
Champ in-the-making
Champ in-the-making
Check the IDGenerator class., you can over-ride this class to the come up with what suits your needs.,
Here is an example for the Framework's code base.,

<code>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="processEngineConfiguration"
  class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">
 
  <property name="jdbcUrl" value="jdbc:h2:mem:activiti-uuid-generator-test;DB_CLOSE_DELAY=1000;MVCC=TRUE" />

  <property name="databaseSchemaUpdate" value="true" />
 
  <property name="idGenerator">
   <bean class="org.activiti.engine.impl.persistence.StrongUuidGenerator" />
  </property>

</bean>

</beans>
</code>

Obviously you can also check the GitHub link here for the complete sample application.
example link

cheers

sudhi123
Champ in-the-making
Champ in-the-making
Sorry, but i dont think it solves my problem. I think the question asked was how to generate PROC_INST_ID_ sequentially,  like 1, 2 , 3 etc.

Right now it is like , 1, 15, 45, depends on how many getTNextid() being called by ID generator.

Ideally i want for ProcessInstance, i want to have have a unique id Generator, is this possible?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Sudhi.

Activiti Id generator interface does not distinguish between processes, tasks, executions… .

public interface IdGenerator {
  String getNextId();
}
And there is only one generator in the engine.

I would recommend to use businessKey in the process instance.

  /**
   * Starts a new process instance in the latest version of the process
   * definition with the given key.
   *
   * A business key can be provided to associate the process instance with a
   * certain identifier that has a clear business meaning. For example in an
   * order process, the business key could be an order id. This business key can
   * then be used to easily look up that process instance , see
   * {@link ProcessInstanceQuery#processInstanceBusinessKey(String)}. Providing
   * such a business key is definitely a best practice.
   *
   * Note that a business key MUST be unique for the given process definition.
   * Process instance from different process definition are allowed to have the
   * same business key.
   *
   * The combination of processdefinitionKey-businessKey must be unique.
   *
   * @param processDefinitionKey
   *          key of process definition, cannot be null.
   * @param businessKey
   *          a key that uniquely identifies the process instance in the context
   *          or the given process definition.
   * @throws ActivitiObjectNotFoundException
   *           when no process definition is deployed with the given key.
   */
  ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey);

Regards
Martin

sudhi123
Champ in-the-making
Champ in-the-making
ok thank you.