我们正在尝试为参与者步骤实施超时。但这似乎不起作用。当我将超时配置为即时时,我们可以看到超时行为,但是当我们选择实际时间为1小时时。在指定的时间间隔后,它不会超时。要实现此目的,我们还有其他配置吗?
答案 0 :(得分:0)
这是因为我看到的com.adobe.granite.workflow.core.job.WorkflowJobUtils中的错误。当我将“参与者”步骤的超时设置为1h时,日志中会显示消息
03.10.2018 16:26:10.681 *DEBUG* [0:0:0:0:0:0:0:1 [1538573170619] POST /etc/workflow/instances HTTP/1.1] com.adobe.granite.workflow.core.job.WorkflowJobUtils calling createTimeoutJob for workitem /etc/workflow/instances/server0/2018-10-03/test-model_98/workItems/node1_etc_workflow_instances_server0_2018-10-03_test-model_98
03.10.2018 16:26:10.681 *DEBUG* [0:0:0:0:0:0:0:1 [1538573170619] POST /etc/workflow/instances HTTP/1.1] com.adobe.granite.workflow.core.job.WorkflowJobUtils create timeout event {com.adobe.granite.workflow.console.timeout.job=com.adobe.granite.workflow.job.TimeoutJob@989455c, event.timed.date=Wed Nov 14 08:26:10 MSK 2018, event.timed.id=/etc/workflow/instances/server0/2018-10-03/test-model_98/workItems/node1_etc_workflow_instances_server0_2018-10-03_test-model_98_1538573170632}
“ event.timed.date = MSK 2018年11月14日星期三”,该步骤是在10月3日下午4点分配给参与者的。您可以添加记录器并从侧面检查,我正在使用AEM 6.3。这是步骤配置:
Long timeout = (Long)item.getNode().getMetaDataMap().get("timeoutMillis", Long.class);
Date date = calculateDate(timeout.longValue(), addOffset);
props.put("event.timed.date", date);
LOGGER.debug("create timeout event {} ", props);
jobBuilder.properties(props);
List<String> errors = new ArrayList();
ScheduledJobInfo result = jobBuilder.schedule().at(adjustDate(date)).add(errors);
private static Date calculateDate(long seconds, boolean addOffset) {
Calendar cal = Calendar.getInstance();
long millies = seconds * 1000L;
if (addOffset) {
millies += cal.getTimeInMillis();
}
cal.setTimeInMillis(millies);
return cal.getTime();
}
您在calculateDate方法中看到了他们期望的秒数,但是实际上为“ 1h”选项设置了毫秒数3,600,000。因此他们将其乘以1 000,得到3,600,000毫秒或3,600,000秒,1 000小时或41.6天。
您可以在此处/ libs / cq / workflow / components / model / step / tab_common / items / timeout / items / timeout / options中为“超时”下拉列表添加新选项。
在我添加了值为“ 1”的新选项之后,超时处理程序被调用:
03.10.2018 16:38:54.200 *DEBUG* [0:0:0:0:0:0:0:1 [1538573934182] POST /etc/workflow/instances HTTP/1.1] com.adobe.granite.workflow.core.job.WorkflowJobUtils calling createTimeoutJob for workitem /etc/workflow/instances/server0/2018-10-03/test-model_99/workItems/node1_etc_workflow_instances_server0_2018-10-03_test-model_99
03.10.2018 16:38:54.201 *DEBUG* [0:0:0:0:0:0:0:1 [1538573934182] POST /etc/workflow/instances HTTP/1.1] com.adobe.granite.workflow.core.job.WorkflowJobUtils create timeout event {com.adobe.granite.workflow.console.timeout.job=com.adobe.granite.workflow.job.TimeoutJob@267dc5f3, event.timed.date=Wed Oct 03 16:38:55 MSK 2018, event.timed.id=/etc/workflow/instances/server0/2018-10-03/test-model_99/workItems/node1_etc_workflow_instances_server0_2018-10-03_test-model_99_1538573934194}
03.10.2018 16:38:59.335 *INFO* [sling-oak-observation-212] org.apache.sling.event.impl.jobs.queues.JobQueueImpl.Granite Workflow Timeout Queue Starting job queue Granite Workflow Timeout Queue
03.10.2018 16:38:59.336 *INFO* [sling-oak-observation-212] org.apache.sling.event Service [QueueMBean for queue Granite Workflow Timeout Queue,14915, [org.apache.sling.event.jobs.jmx.StatisticsMBean]] ServiceEvent REGISTERED
03.10.2018 16:38:59.435 *DEBUG* [sling-threadpool-7e90cbd1-c78f-4aff-add9-eba2c792e8fe-(apache-sling-job-thread-pool)-22-Granite Workflow Timeout Queue(com/adobe/granite/workflow/timeout/job)] com.adobe.granite.workflow.core.job.TimeoutHandler process timeout job for event JobImpl [properties=org.apache.sling.api.wrappers.ValueMapDecorator@136322bc : {slingevent:application=fa67a921-cc59-4097-953a-a6e69ff5b718, jcr:created=java.util.GregorianCalendar[time=1538573939311,areFieldsSet=true,areAllFieldsSet=true,lenient=false,zone=sun.util.calendar.ZoneInfo[id="GMT+03:00",offset=10800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=9,WEEK_OF_YEAR=40,WEEK_OF_MONTH=1,DAY_OF_MONTH=3,DAY_OF_YEAR=276,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=38,SECOND=59,MILLISECOND=311,ZONE_OFFSET=10800000,DST_OFFSET=0], event.timed.date=Wed Oct 03 16:38:55 MSK 2018, slingevent:created=java.util.GregorianCalendar[time=1538573939203,areFieldsSet=true,areAllFieldsSet=true,lenient=false,zone=sun.util.calendar.ZoneInfo[id="GMT+03:00",offset=10800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=9,WEEK_OF_YEAR=40,WEEK_OF_MONTH=1,DAY_OF_MONTH=3,DAY_OF_YEAR=276,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=38,SECOND=59,MILLISECOND=203,ZONE_OFFSET=10800000,DST_OFFSET=0], event.job.queuename=Granite Workflow Timeout Queue, event.job.queued.time=java.util.GregorianCalendar[time=1538573939203,areFieldsSet=true,areAllFieldsSet=true,lenient=false,zone=sun.util.calendar.ZoneInfo[id="GMT+03:00",offset=10800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=9,WEEK_OF_YEAR=40,WEEK_OF_MONTH=1,DAY_OF_MONTH=3,DAY_OF_YEAR=276,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=38,SECOND=59,MILLISECOND=203,ZONE_OFFSET=10800000,DST_OFFSET=0], jcr:createdBy=sling-event, sling:resourceType=slingevent:Job, slingevent:eventId=2018/10/3/16/38/fa67a921-cc59-4097-953a-a6e69ff5b718_92, event.timed.id=/etc/workflow/instances/server0/2018-10-03/test-model_99/workItems/node1_etc_workflow_instances_server0_2018-10-03_test-model_99_1538573934194, event.job.application=fa67a921-cc59-4097-953a-a6e69ff5b718, event.job.retries=10, com.adobe.granite.workflow.console.timeout.job=com.adobe.granite.workflow.job.TimeoutJob@29a9a2f7, event.job.started.time=java.util.GregorianCalendar[time=1538573939376,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Minsk",offset=10800000,dstSavings=0,useDaylight=false,transitions=69,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2018,MONTH=9,WEEK_OF_YEAR=40,WEEK_OF_MONTH=1,DAY_OF_MONTH=3,DAY_OF_YEAR=276,DAY_OF_WEEK=4,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=38,SECOND=59,MILLISECOND=376,ZONE_OFFSET=10800000,DST_OFFSET=0], jcr:primaryType=slingevent:Job, event.job.retrycount=0, :sling:jobs:asynchandler=org.apache.sling.event.impl.jobs.JobConsumerManager$JobConsumerWrapper$1@8f1e51d, event.job.topic=com/adobe/granite/workflow/timeout/job}, topic=com/adobe/granite/workflow/timeout/job, path=/var/eventing/jobs/assigned/fa67a921-cc59-4097-953a-a6e69ff5b718/com.adobe.granite.workflow.timeout.job/2018/10/3/16/38/fa67a921-cc59-4097-953a-a6e69ff5b718_92, jobId=2018/10/3/16/38/fa67a921-cc59-4097-953a-a6e69ff5b718_92]
03.10.2018 16:38:59.443 *DEBUG* [sling-threadpool-7e90cbd1-c78f-4aff-add9-eba2c792e8fe-(apache-sling-job-thread-pool)-22-Granite Workflow Timeout Queue(com/adobe/granite/workflow/timeout/job)] com.adobe.granite.workflow.core.job.TimeoutHandler process timeout job for work item /etc/workflow/instances/server0/2018-10-03/test-model_99/workItems/node1_etc_workflow_instances_server0_2018-10-03_test-model_99
03.10.2018 16:38:59.701 *INFO* [sling-threadpool-7e90cbd1-c78f-4aff-add9-eba2c792e8fe-(apache-sling-job-thread-pool)-22-Granite Workflow Timeout Queue(com/adobe/granite/workflow/timeout/job)] etc.workflow.scripts.test-timeout-handler$ecma
Test timeout handler /etc/workflow/scripts/test-timeout-handler.ecma is called