Set a custom generated id for both process instance and jobs

Hi! I need to set my process instance id on start method invocation as task creation where I can pass a String id or not over newTask method.

Can I pass an Id as arg or set it using my uuid generator for both process instance and jobs?

Thanks a lot


if you want to use a custom id generator you can set the property idGenerator in the ProcessEngineConfiguration. See the documentation for more information.

Best regards,

Thanks for reply @Zelldon I read yesterday this section.

documentation is very good in all.

As I’ m using more than one process engine, can I use it as single generator for each process engine?

thanks a lot! regards

Hi @Zelldon I try to implement the IdGenerator interface as my a custom generator impementation but it return this error:

ENGINE-03002 Cannot add TRANSIENT entity with id ‘ae3a6b50-a7c3-4188-b774-bd9a82368506’
and type ‘class org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity’
into cache. An entity with the same id and type is already in state ‘TRANSIENT’

Can I do it?


It seems that your IdGenerator generates no unique id’s since an entity with the same id is already in the cache.
Maybe you have to improve the implementation of the IdGenerator?

Best regards,

Yes @Zelldon , this error occurred with each id I try to pass rather id provided by camunda IdGenerator.

I would implement a custom IdGenerator, can I do it?

Hey Devj,

yes you can do it. How do you set the ID currently?


Thanks for reply @Zelldon I tried both a simple java UUID and providing during test another kind of UUID for example: AVdhY8XWExrkjWnZiSAT but it still doesn’t work


How can I set IdGenerator for a container managed process engine as a process engine configuration?

I created a process engine bean using the JndiObjectFactoryBean from a JNDI Process Engine defined into my wildly server, but I can’t run it

Thanks a lot

import com.fasterxml.uuid.EthernetAddress;
import com.fasterxml.uuid.Generators;
import com.fasterxml.uuid.impl.TimeBasedGenerator;
import org.camunda.bpm.engine.impl.cfg.IdGenerator;
import org.camunda.bpm.engine.impl.persistence.StrongUuidGenerator;
import org.springframework.stereotype.Component;

public class CustomUuidGenerator implements IdGenerator {

// different ProcessEngines on the same classloader share one generator.
protected static volatile TimeBasedGenerator timeBasedGenerator;

public CustomUuidGenerator() {

protected void ensureGeneratorInitialized() {
    if (timeBasedGenerator == null) {
        synchronized (StrongUuidGenerator.class) {
            if (timeBasedGenerator == null) {
                timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
// You can implement your own ID generator here
// The customuuidgenerator class will be loaded before the idgenerator is defined inside camunda
public String getNextId() {
    return timeBasedGenerator.generate().toString().replaceAll("-","");


How can you override processEngine id generator. Did you create customProcessEngineConfiguration?