How is the PROC_INST_ID generated?

509 views
Skip to first unread message

Jan Hiemer

unread,
Sep 6, 2013, 5:48:10 AM9/6/13
to camunda-...@googlegroups.com
Hello camunda community,
Does somebody know how the PROC_INST_ID is generated? Is there a sequence in the database?
It seems so, that the camunda process engine has one global number which grows with every instance of an element (process, task, gateway, ...).
My process portal users are familiar with numbers between 1 and 99999 like in bugzilla or jira to 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 camunda engine?
One workaround is to assign my own numbers and put them as process variable, but thats not so beautiful, because then I have two ID's for one instance :-(.

Thanks for your ansers,
Jan

Daniel Meyer

unread,
Sep 9, 2013, 5:31:03 AM9/9/13
to Jan Hiemer, camunda-...@googlegroups.com

Hi Jan,

 

you can plug in  a custom org.camunda.bpm.engine.impl.cfg.IdGenerator implementation. There are two default implementations

1.       a database backed sequence generator

2.       a UUID generator-based implementation.

 

The IdGenerator is set on the process engine configuration class.

 

Cheers,

Daniel Meyer

Jan Hiemer

unread,
Sep 9, 2013, 6:53:02 AM9/9/13
to camunda-...@googlegroups.com, Jan Hiemer
Hi Daniel,
Thanks for your answer which helps me to understand where the IDs come from.
But to change the implementation of the IdGenerator doesn't help me, because this would change the whole generation mechanism for all activities / elements.
I need a separate generator only for the ProcessInstanceIds.
Do you have an idea to achieve this?

Cheers, Jan

Daniel Meyer

unread,
Sep 9, 2013, 7:47:09 AM9/9/13
to Jan Hiemer, camunda-...@googlegroups.com

Hi Jan,

 

currently it would be difficult to exchange Id-Generation for process instances only (but feel free to submit a pull request adding a second method to the IdGenerator Interface.)

 

What about the business key? Maybe you could use the business key for providing a “uman-digestable” identifier for a process instance?

 

Cheers,

Daniel Meyer

--
You received this message because you are subscribed to the Google Groups "camunda BPM users & process application developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camunda-bpm-us...@googlegroups.com.
To post to this group, send email to camunda-...@googlegroups.com.

Jan Hiemer

unread,
Sep 10, 2013, 2:01:59 AM9/10/13
to camunda-...@googlegroups.com, Jan Hiemer
Good Morning Daniel,
here is the feature request: https://app.camunda.com/jira/browse/CAM-1248

Using the business key is possible, but then it is blocked for other purposes :-(.
What will be the easiest way to generate the id and put it in the business key? Changing the IdGenerator implementation wouldn't help.
Creating an own DbIdGenerator which stores the ID's in the PropertyTable? Use an ExecutionListener on StartEvent of the Process?

Best regards, Jan

Bernd Rücker (camunda)

unread,
Sep 10, 2013, 2:47:04 AM9/10/13
to Jan Hiemer, camunda-...@googlegroups.com

Hi Jan.

 

adding a listener to the start event will work prefectly, but if I remember it right the businessKey will not be added to the history in this case (as this is already too late). If that is OK I think that is a good solution. If you need the history you have to make sure to generate the businessKey yourself and add it to "startProcessInstanceByX".

 

Cheers

Bernd

 

Von: camunda-...@googlegroups.com [mailto:camunda-...@googlegroups.com] Im Auftrag von Jan Hiemer
Gesendet: Dienstag, 10. September 2013 08:02
An: camunda-...@googlegroups.com
Cc: 'Jan Hiemer'
Betreff: Re: How is the PROC_INST_ID generated?

 

Good Morning Daniel,

--

Daniel Meyer

unread,
Sep 10, 2013, 7:46:14 AM9/10/13
to Bernd Rücker (camunda), Jan Hiemer, camunda-...@googlegroups.com

Hi Guys,

 

As Bernd already suggested, changing the business key at runtime of a process instance is not really supported and should be avoided if possible. This is why it is not exposed in public API. The semantics are unclear, what if it is used in correlation? What about sub process instances which are already started etc and have been propagated the same business key. We figured that it would be complicated to implement it properly for all cases.

 

The business key should be set before the process instance starts (ie. passed to startProcessInstanceByX).

 

Getting back to the IdGenerator:

What we could easily do is add a second method to the IdGenerator interface:

 

public interface IdGenerator {

 

  String getNextId();

  String getNextProcessInstanceId();

 

}

 

@Jan: chances of CAM-1248 being done would be greatly increased by a pull request ;)

 

Cheers,

Daniel Meyer

Jan Hiemer

unread,
Sep 12, 2013, 8:38:58 AM9/12/13
to camunda-...@googlegroups.com, Bernd Rücker (camunda), Jan Hiemer
Hi Daniel,
If you implement the new method in the IdGenerator interface, will you use it in your DbIdGenerator class for generating user friendly numbers?
And do you switch the invocation places where process instances are created to the new method?

When will the 7.1 be released?
What do you mean with pull request? I'am not so familiar with jira. Was a feature request wrong?

Best regards, Jan

Daniel Meyer

unread,
Sep 14, 2013, 2:52:58 AM9/14/13
to Jan Hiemer, camunda-...@googlegroups.com, Bernd Rücker (camunda)

Hi Jan,

 

what I had in mind was that maybe you could give it a try adding the method yourself and if you succeed provide the code using a pull request on github J

https://help.github.com/articles/using-pull-requests

 

I fear that this feature would not be a high priority for us, this is want I meant with „A pull request could improve the chances of this being done” J

 

7.1 will be released before End of March 2014.

 

Cheers,

Daniel Meyer

Jan Hiemer

unread,
Sep 16, 2013, 2:34:22 AM9/16/13
to camunda-...@googlegroups.com, Jan Hiemer, Bernd Rücker (camunda)
Good Morning Daniel,
Thanks for all your answers. Now I know what you want ;-).
I haven't worked with GIT yet, but maybe I will give it a try.

Cheers, Jan
Reply all
Reply to author
Forward
0 new messages