Different timeout for a step in workflow for different workflow instances | Community
Skip to main content
Level 2
October 16, 2015
Solved

Different timeout for a step in workflow for different workflow instances

  • October 16, 2015
  • 5 replies
  • 2019 views

Hi,

I want to set a different timeout for a participant step in a workflow for different instances of the workflow running on different payloads. For e.g. I want to set a timeout of 2 hours for 1 instance of a workflow running on payload A. And for another instance of the same workflow on a different payload, Payload B, I want to set the timeout as 3 hours.Please tell if anybody has any pointers on this.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

Hmmm...  Sorry I misunderstood run mode with workflow instance.

You can write a new class which extends from AutoAdvance and implements the AbsoluteTimeoutHandler interface[1] & in getTimeoutDate have method like [2] & can avoid OR split.

[1]   http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/workflow/job/AbsoluteTimeoutHandler.html

[2]

if (isPayLoadA()) {

  return 10 min;

} else if (isPayLoadB()) {

  return 15 min;

}

else {

  return -1; // timeout now

}

5 replies

Sham_HC
Level 10
October 16, 2015

Utilize runmode config here.

Level 2
October 16, 2015

runmode config will not help here. It's changing the configuration parameters for a CQ instance. I am talking here about a workflow instance.

Sham_HC
Level 10
October 16, 2015

Why not?  Unless i misunderstood your requirement.  Implement the osgi bundle with the AbsoluteTimeoutHandler & in the bundle you can get run mode parameter. 

October 16, 2015

Hi Sham,

If I am not wrong his requirement is adding 2 participant steps (they will be in or split) in the same work flow which has 2 different timeouts. Based on the payload some times it has to take right step and some times it will go through left step. I tried this but by default it is taking latest instance timeout setting and it is not completing previous instances.

Below are the logs in time out. My understanding is, it is taking only latest timout settings per workflow.

In a nutshell can we have more than one step with different timeouts?

12.12.2013 17:57:40.376 *INFO* [pool-6-thread-2] org.apache.sling.event.impl.jobs.queues.TopicRoundRobinJobQueue.Granite Workflow Timeout Queue Stopped job queue Granite Workflow Timeout Queue
12.12.2013 17:57:40.377 *INFO* [pool-6-thread-2] org.apache.sling.event Service [QueueMBean for queue Granite Workflow Timeout Queue,1974] ServiceEvent UNREGISTERING
12.12.2013 17:57:40.378 *INFO* [pool-6-thread-2] org.apache.sling.event.impl.jobs.queues.TopicRoundRobinJobQueue.Granite Workflow Queue Stopped job queue Granite Workflow Queue
12.12.2013 17:57:40.379 *INFO* [pool-6-thread-2] org.apache.sling.event Service [QueueMBean for queue Granite Workflow Queue,1975] ServiceEvent UNREGISTERING
12.12.2013 17:58:15.128 *INFO* [pool-6-thread-4] org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager cachename=versionBundleCache[ConcurrentCache@76a33ed9], elements=5117, usedmemorykb=4821, maxmemorykb=8192, access=94234, miss=5117
12.12.2013 17:58:15.151 *INFO* [Apache Sling Job Background Loader] org.apache.sling.event Service [QueueMBean for queue Granite Workflow Timeout Queue,1976] ServiceEvent REGISTERED
12.12.2013 17:58:15.154 *INFO* [Apache Sling Job Queue Granite Workflow Timeout Queue] org.apache.sling.event.impl.jobs.queues.TopicRoundRobinJobQueue.Granite Workflow Timeout Queue Starting job queue Granite Workflow Timeout Queue
12.12.2013 17:58:15.215 *INFO* [pool-7-thread-22] org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager cachename=crx.defaultBundleCache[ConcurrentCache@3f73b038], elements=3252, usedmemorykb=8183, maxmemorykb=8192, access=414274, miss=115972
Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015

Hmmm...  Sorry I misunderstood run mode with workflow instance.

You can write a new class which extends from AutoAdvance and implements the AbsoluteTimeoutHandler interface[1] & in getTimeoutDate have method like [2] & can avoid OR split.

[1]   http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/workflow/job/AbsoluteTimeoutHandler.html

[2]

if (isPayLoadA()) {

  return 10 min;

} else if (isPayLoadB()) {

  return 15 min;

}

else {

  return -1; // timeout now

}