There is an integrated Snaker workflow in the project, now the user has the need, want to give each link set a task timeout not handle the reminder function. A study, the realization is still relatively simple:
1. Reliance
Snaker default support quartz timer scheduling framework, only need to rely on the Snaker-quartz package.
2, configuration
The implementation class of timer scheduling and time schedule control in Snaker.xml
<bean class= "Org.snaker.engine.impl.SchedulerInterceptor"/>
<bean class= "Org.snaker.engine.scheduling.quartz.QuartzScheduler"/>
If you use a different timing scheduling framework, you need to implement the IScheduler interface and replace the Quartzscheduler class configuration
The previous two steps have completed the time frame of the configuration work, the following can be used for reminders, time-out automatic execution to do custom extensions.
3. Realize
Write a custom reminder class to implement the Ireminder interface. and configured into Snaker.xml.
</>
Snakerreminder:
ImportNet.Jqsoft.Hecv.Portal.Commonapiaction; ImportOrg.Apache.Commons.Logging.Log; ImportOrg.Apache.Commons.Logging.Logfactory; ImportOrg.Snaker.Engine.Entity.Process; ImportOrg.Snaker.Engine.Model.Nodemodel; ImportOrg.Snaker.Engine.Scheduling.Ireminder; ImportOrg.Zcframework.Workflow.Reminder.Mailreminder; ImportJava.Util.Map; Public classSnakerreminderImplementsIreminder{ private staticLog Logger= Logfactory.GetLog(Snakerreminder.class); Public voidRemind(Process process, String orderId, String taskId, Nodemodel Nodemodel, Map<String, Object>Data) { Logger.Info("OrderId:"+OrderId); Logger.Info("TaskId:"+TaskId); Logger.Info("Process:"+Process.GetDisplayName()); Logger.Info("Nodemodel:"+Nodemodel.GetDisplayName()); for(String Key:Data.Keyset()){ Logger.Info(Key+":"+Data.Get(Key)); } } }
4. Callback Class
Import Org.Apache.Commons.Logging.Log; ImportOrg.Apache.Commons.Logging.Logfactory; ImportOrg.Snaker.Engine.Entity.Task; ImportOrg.Snaker.Engine.Scheduling.Jobcallback; ImportJava.Util.List; /** * Created by Administrator on 2017-4-20. */ Public classSnakerjobcallbackImplementsJobcallback{ private staticLog Logger= Logfactory.GetLog(Snakerreminder.class); @Override Public voidCallback(String s, List<Task>List) { Logger.Info("s:"+S); } }
The path to the callback class is configured in the workflow ...
5. Other
ReminderTime is a variable that indicates the start time of the reminder, and you need to pass this variable value when you invoke the API, and the value is of type date.
Reminderrepeat is a number that indicates the time of the repeat reminder, in minutes
The default reminder ends once, and if you want to be reminded multiple times, you can configure the Scheduler.repeat property in Snaker.properties, which is a number indicating the number of reminders.
Holiday Configuration (snaker.properties):
#是否启用节假日, default is False
Scheduler.usecalendar=true/false
#节日配置, the format is YYYY-MM-DD,...
Scheduler.holidays=2014-12-26,2014-12-27
#工作日设置, formatted as 1,2,3...7, indicating Monday to Sunday
scheduler.weeks=1,2,3,4,5
#工作时间设置, format for 8:00-18:00
scheduler.worktime=8:00-18:00