for project needed, I need a button when I click it it will trigger a scheduler job immediately in liferay 6.1.1. I know before liferay 4.2 there is a API JobScheduler.triggerJob() to make it happen. but in the 6.1.1 this API is removed, is there any other way I can do this? Thanks a lot.
Best How To :
I guess better way is to execute your process service method on button click event rather than manually triggering a job. If you already have a job, it can call the same process service method.
However below information can be useful if you want to got with custom schedule a job.
SchedulerEngineHelperUtil.schedule menthod will accept custom trigger. Liferay allows to specify cron express as trigger. You can use below expression to trigger immediately.
* * * * * ? *
An example code custom scheduler can be found in LayoutServiceImpl.schedulePublishToLive method. I believe you can do similar with above cron express to invoke a job immediately.
Trigger trigger = new CronTrigger(
jobName, groupName, schedulerStartDate, schedulerEndDate, cronText);
trigger, StorageType.PERSISTED, description,
DestinationNames.LAYOUTS_LOCAL_PUBLISHER, publisherRequest, 0);