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?
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.
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.
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?
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.
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.