# How do i ensure that a processID never is repeated?

**URL:** <https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571>\
**Category:** Flowable Engine\
**Created:** [February 1, 2018, 8:00am UTC](https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571 "2018-02-01T08:00:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_a](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@Martin\_a](https://forum.flowable.org/u/Martin_a)\
**Post date:** [February 1, 2018, 8:00am UTC](https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571/1 "2018-02-01T08:00:44Z")

</div>

Hello 🙂 Im working with a project where we need to ensure that a processID never is repeated, I’ve looked around in the source code for flowable, but haven’t managed to found how a processID is set on a new ProcessInstance.

What im looking for is how the counter for processID works, if a process has id 123 and it ends, I need to make sure a new process can’t get the ID 123.

I haven’t found anything in the Javadocs either, can anyone point me towards where i might look for answers?

Best regards, Martin 🙂

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [February 1, 2018, 8:12am UTC](https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571/2 "2018-02-01T08:12:46Z")

</div>

Hi Martin

Have a look on org.flowable.engine.common.impl.cfg.IdGenerator interface and its implementations.

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![Martin\_a](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@Martin\_a](https://forum.flowable.org/u/Martin_a)\
**Post date:** [February 1, 2018, 8:16am UTC](https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571/3 "2018-02-01T08:16:01Z")

</div>

Ok, thanks a lot 🙂 I will have a look!

---

<div class="post-metadata">

**Author:** ![Martin\_a](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@Martin\_a](https://forum.flowable.org/u/Martin_a)\
**Post date:** [February 2, 2018, 11:16am UTC](https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571/5 "2018-02-02T11:16:03Z")

</div>

Hello again, sorry if im necroing this thread from yesterday, i’ve looked around a bit but can’t really seem to understand where “IdBlock execute” in “GetNextIdBlockCmd” gets the value “next.dbid” from. The entire row looks like this:

PropertyEntity property = (PropertyEntity)CommandContextUtil.getPropertyEntityManager(commandContext).findById(“next.dbid”);

From my understanding it collects some id from the database, to know where to start the next block? Do you know where i can read more about this “findbyid” and how it functions?

Best regards Martin.A 🙂

---

<div class="post-metadata">

**Author:** ![martin.grofcik](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/martin.grofcik/32/71_2.png) [@martin.grofcik](https://forum.flowable.org/u/martin.grofcik)\
**Post date:** [February 2, 2018, 11:59am UTC](https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571/6 "2018-02-02T11:59:49Z")

</div>

Hi Martin.  
org.flowable.engine.impl.db.DbIdGenerator#getNextId is called when new object is created. Generator is configured in the XYZ\_EngineConfiguration.

> [@Martin\_a](#):
>
> where we need to ensure that a processID never is repeated

It depends on the EngineCofiguration which IdGenerator is used. By default it is DbIdGenerator.

```
@Override
public void initIdGenerator() {
    if (idGenerator == null) {
        CommandExecutor idGeneratorCommandExecutor = getCommandExecutor();
        DbIdGenerator dbIdGenerator = new DbIdGenerator();
        dbIdGenerator.setIdBlockSize(idBlockSize);
        dbIdGenerator.setCommandExecutor(idGeneratorCommandExecutor);
        dbIdGenerator.setCommandConfig(getDefaultCommandConfig().transactionRequiresNew());
        idGenerator = dbIdGenerator;
    }
}

```

Whenever org.flowable.engine.impl.db.DbIdGenerator#getNextId is called it checks whether new block allocation is needed and updates ACT\_GE\_PROPERTY property next.dbid. The allocation is done in GetNextIdBlockCmdGetNextIdBlockCmd.

Regards  
Martin

---

<div class="post-metadata">

**Author:** ![Martin\_a](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@Martin\_a](https://forum.flowable.org/u/Martin_a)\
**Post date:** [February 2, 2018, 12:41pm UTC](https://forum.flowable.org/t/how-do-i-ensure-that-a-processid-never-is-repeated/1571/7 "2018-02-02T12:41:09Z")

</div>

Okay, i understand now 🙂 Thanks a lot for all the help!
