cancel
Showing results for 
Search instead for 
Did you mean: 

Switching to AsyncExecutor

sankalpn
Champ in-the-making
Champ in-the-making
Hi all, I am trying to switch to AsyncExecutor and want to set it up in a clustered mode (enabled on all servers). My process engine configuration looks like this:


  @Bean(name = "processEngineConfiguration")
  public ProcessEngineConfigurationImpl processEngineConfiguration() {
    SpringProcessEngineConfiguration processEngineConfiguration = new SpringProcessEngineConfiguration();
    processEngineConfiguration.setClassLoader(getClass().getClassLoader());
    processEngineConfiguration.setDataSource(dataSource()); // This is a postgres DB
    processEngineConfiguration.setDatabaseSchema(activitiSchema); // Have a separate schema for activiti
    processEngineConfiguration.setDatabaseSchemaUpdate("true");
    processEngineConfiguration.setTransactionManager(annotationDrivenTransactionManager());
    processEngineConfiguration.setJobExecutorActivate(false);
    processEngineConfiguration.setAsyncExecutorEnabled(true);
    processEngineConfiguration.setAsyncExecutorActivate(true);
    processEngineConfiguration.setHistory("full");
    processEngineConfiguration.setMailServerHost(mailServer);
    processEngineConfiguration.setMailServerPort(mailServerPort);
    return processEngineConfiguration;
  }


But when I tested a workflow with two servers, I saw both servers executed a task from the same process instance. Is this expected? How can I configure the process engine so that only one server executes any given task?

Thanks,
Sankalp
10 REPLIES 10

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Sankalp,

Was the one job executed twice?

When you have default executor implementation any of the nodes can execute task.
How can I configure the process engine so that only one server executes any given task?
Disable executor on one node.

Regards
Martin

sankalpn
Champ in-the-making
Champ in-the-making
Hi Martin,

     Thanks for quick response. It is indeed desirable to have AsyncExecutor enabled on both servers so that any of them can execute a job. Also, legacy JobExecutor is disabled on both.

     But, what I observed is, the same job was executed twice. First workflow tasks is not idempotent (it depends on third party web service, and cannot be easily made idempotent). The server which executed this task first completed workflow in normal path and the server which executed later triggered error path.

     Now, how do I configure process engine so that any given job is executed only once and AsyncExecutor is still enabled on both servers?

Thanks

jwestra
Champ in-the-making
Champ in-the-making
Hi Martin,

Is "disabling all AsyncExecutors except one" the recommendation from the Activiti Team, in general, for clustered, production Activiti installations?  This is not scalable, nor fault tolerant. 

Were you telling the OP to disable one just to troubleshoot? 

Please provide more information as to why you recommended this to the OP because this impacts many of us on which executor we configure in a clustered environment.

Thanks!
Jason


jbarrez
Star Contributor
Star Contributor
No, the executor should and can be run on multiple nodes.

sankalpn
Champ in-the-making
Champ in-the-making
Thanks for the clarification Joram.

But, why do I see a single task being executed by both AsyncExecutors? Is there some configuration to prevent that?

Thanks,
Sankalp

jbarrez
Star Contributor
Star Contributor
No, that should not happen. The jobs are first locked before they are executed. How did you verify both executors did execute it?

sankalpn
Champ in-the-making
Champ in-the-making
I got logs from same workflow, same service task on both servers. Is there some database/transaction manger level setting for this?

jbarrez
Star Contributor
Star Contributor
and you only had one process instance active?

Transaction should be the default setting (read committed), normally that's the default on all databases we support.

sankalpn
Champ in-the-making
Champ in-the-making
Hi Joram and Martin,

            I thoroughly apologize for any confusion this thread caused. On the malfunctioning server, upstart jar path was changed and it was running an older test binary which had AsyncExecutor and legacy JobExecutor enabled. New jar with updated, correct activiti config did not run to begin with giving us erroneous results. The moment we corrected upstart, we saw correct behavior. Maybe this thread should serve as a lesson. Your clarification about locking tasks is indeed valuable.

Thanks,
Sankalp