ofbiz中job任务应用 http://www.45542.com/kaiyuan-soft/1042025.html
ofbiz进阶分析--Ofbiz开发之 异步服务与计划任务(Job Scheduler) 分析 http://www.tools138.com/create/article/20140315/050036937.html
TemporalExpression表达式:图片在 http://panyongzheng.iteye.com/blog/2084855
示例:现在来定义一个14天后的表达式
<TemporalExpression tempExprId="PM" tempExprTypeId="FREQUENCY" description="Every Other Monday at 5pm" date1="2000-01-03 17:00:00.000" integer1="5" integer2="14"/>
integer1="5" 可以看出规则类型是Day,integer2="14",所以说是14天。
示例:
增加Schedule的定义
/framework/service/data/ScheduledServices.xml
-----------------------------------------------------------------
<TemporalExpression tempExprId="my_job_teId" tempExprTypeId="FREQUENCY" description="20 Second" date1="2014-07-27 12:30:00.000" integer1="13" integer2="20"/> <JobSandbox jobId="my_job_id" jobName="Test Jobs" runTime="2014-07-27 12:30:00.000" serviceName="myScheduleMethod" poolId="pool" runAsUser="system" tempExprId="my_job_teId" maxRecurrenceCount="-1"/>
定义Service配置:在framework或者自定义工程里面的 其中一个services.xml增加service的配置
applications/自定义工程/servicedef/services.xml
-----------------------------------------------------------------
<service name="myScheduleMethod" engine="java" location="com.pandy.MySchedule.SendEmailUtil" invoke="myScheduleMethod" auth="false" use-transaction="false" semaphore="wait"> <description>my demo</description> <attribute name="oper" type="String" mode="IN" optional="true" /> <attribute name="success" type="Object" mode="OUT" optional="true"/> <attribute name="__CUSTOM_JSON_OBEJECT__" type="Object" mode="OUT" optional="true"/> </service>
framework/service/servicedef/services.xml
-----------------------------------------------------------------
<service name="myScheduleMethod" engine="java" location="com.pandy.MySchedule.SendEmailUtil" invoke="myScheduleMethod" auth="false" use-transaction="false" semaphore="wait"> <description>my demo</description> <attribute name="oper" type="String" mode="IN" optional="true" /> <attribute name="success" type="Object" mode="OUT" optional="true"/> <attribute name="__CUSTOM_JSON_OBEJECT__" type="Object" mode="OUT" optional="true"/> </service>
定义Service的类和方法:
com.pandy.MySchedule的方法
-----------------------------------------------------------------
public static Map<String, Object> myScheduleMethod(DispatchContext dctx, Map<String, ? extends Object> context) { //执行的代码 return 一个Map对象,包含的信息参考定义service的xml; }
数据库表:做ant load-demo的时候 自动把上面的配置放到这些表里面,不用理会。
temporal_expression
job_sandbox