How do i ensure that a processID never is repeated?

Hello :slight_smile: 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 :slight_smile:

Hi Martin

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

Regards
Martin

Ok, thanks a lot :slight_smile: I will have a look!

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 :slight_smile:

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

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

1 Like

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