[concern-users] Handling "business days" in timeouts and other timings
Brought to you by:
hengels,
leonchiver
|
From: Andy D. <an...@ma...> - 2005-06-28 16:32:56
|
I would like the ability to specify some of my timeouts in "business days".
For example:
<activity name="Review Entry"
class="com.marathon.workflow.concern.MAsynchronousActivity"
asynchronous="true" user="true" optional="false" timeout="86400">
timeout="86400" represents 24 hours (1 day), but if this activity is started
at 4:00 PM on Friday, I'd like it to not timeout until 4:00 PM on Monday. If
started at 4:00 PM on Monday, then it should timeout at 4:00 PM on Tuesday,
and so on. Has anyone else needed to solve this issue? If so, what was your
approach? Ideally, it would be neat if I could do something like this:
<activity name="Review Journal Entry"
class="com.marathon.workflow.concern.MAsynchronousActivity"
asynchronous="true" user="true" optional="false" timeout="86400"
time-unit="business-seconds">
For now, I'm taking the approach of using an environment variable:
<activity name="Review Entry"
class="com.marathon.workflow.concern.MAsynchronousActivity"
asynchronous="true" user="true" optional="false" timeout="86400">
<env-enry>
<env-entry-name>time-unit</env-entry-name>
<env-entry-type>java.lang.String</entry-entry-type>
<env-entry-value>business-seconds</entry-entry-value>
</env-entry>
</activity>
And then manually adjusting the return value of "getTimeout()" from my
AsynchronousActivity implementation.
If this functionality were moved into the Con:cern core, we would probably
want to use an interface that the end-developer can implement, much like
Quartz does. Quartz allows you to handle "business" days via this interface:
public interface Calendar {
public boolean isTimeIncluded(long timeStamp);
public long getNextIncludedTime(long timeStamp);
}
You just do this to adjust time:
long now = System.currentTimeMillis();
if(!calendar.isTimeIncluded(now + timeout)) {
return (calendar.getNextIncludedTime(now + timeout) - now);
} else {
return timeout;
}
|