To manually create a job using the Activiti internal API (Job)

Source: Internet
Author: User
Tags date now

Most of the time, we imagined Activiti to join some of our own timing processes, just as they did at timed events. However, timing start events have great limitations, such as time, number of cycles, and cycle intervals that must be specified, which can not be processed for some processes that calculate time and start based on actual conditions.
Through a series of source code analysis, finally found the way to manually create a job, the code is as follows:
Time Calculation Date now = new Date ();//delay is the time variable of the current time, the date target = new Date (now.gettime () + delay * 60 * 1000);//Time Event declaration Tim erentity timer = new timerentity (); Timer.setduedate (target); Timer.setexclusive (true); Timer.setjobhandlerconfiguration ("Customprocesskey");//deposit The process required to start keytimer.setjobhandlertype ( Timerstarteventjobhandler.type);//Save Job Event Context.getcommandcontext (). Getjobentitymanager (). Schedule (timer);

The code snippet works by simply adding a record to the Act_ru_job table, but when the Activiti configuration is enabled (see Code below), the Activiti process engine triggers the specified process at the specified time.
<property name= "Jobexecutoractivate" value= "true"/>

At this point, we can manually under the control of the code, at an indeterminate time (program computing) points, start any (specify key) process, greatly facilitate the customization of process execution.

To manually create a job using the Activiti internal API (Job)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.