cancel
Showing results for 
Search instead for 
Did you mean: 

JobExecutor not used on start of workflow

robdiana72
Champ in-the-making
Champ in-the-making

I have added a custom JobExecutor based on the information in another question ( ), but I noticed that the JobExecutor does not get used when starting a new workflow. Because a process instance does not get persisted until a "stopping point" like a user task, the JobExexcutor does not see the job. I have tried following the source to see if there is some way to make it work, but I am having problems with that. Any ideas?

8 REPLIES 8

daisuke-yoshimo
Star Collaborator
Star Collaborator

> I have tried following the source to see if there is some way to make it work

Sorry, but your source does not seem to be attached.

Sorry that wasn't clear. I mean that I tried following the logic of the Activiti source code for when you start a workflow and could not see how to either persist the workflow immediately or see any hooks to change how things were executed.

I would like to cooperate, but I'm sorrty that I cannot understand your description.

If possible, please share the details of what you did like Java code of JobExecutorImpl , Processengineconfiguration setting, process to understand your situation.

We create a ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration() and set some of the basic attributes. Then we call processEngineConfiguration.setJobExecutor(new MyCustomExecutor()) to set our custom job executor.

Generally, we start workflows using:

RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(workflowKey, variables);

If a java service task is the first node in the process definition, that service task gets executed by Activiti immediately. The task information does not get persisted to the database to allow the custom JobExecutor to read the job. Does that make sense?

cjose
Elite Collaborator
Elite Collaborator

If you want the job executor to process the service task for you, make the service task "async" to get a job created. Otherwise the service task after start event gets processed in the same thread that starts the process instance. Please read async-continuations for more details.

Cheers,

Ciju

robdiana72
Champ in-the-making
Champ in-the-making

Making the task "async" means it runs asynchronously, and anything after that job will get run as well. We would need the ability for multiple jobs in the process to run serially.

cjose
Elite Collaborator
Elite Collaborator

Making it "async" doesn't mean that the next step in the process will get executed. This setting is purely for asynchronous continuation. A job will be created when a process reaches an async step and job executor will pick it up and execute the job from that point. Please check Activiti User Guide  for more details on this setting.

Ciju

> The task information does not get persisted to the database to allow the custom JobExecutor to read the job. Does that make sense?

Thanks for the explanation.
Could you share your JobExecutor code to understand details about your needs.