[rules-users] TimerService vs TimeMachine and date-effective

Mark Proctor mproctor at codehaus.org
Tue Jun 7 17:30:08 EDT 2011


On 07/06/2011 21:35, David Goldstein wrote:
> Mark,
>
> Thanks.  Based upon your discussion and the manuals, I was looking for
> the Quartz jars but haven't been seeing them.  Are they bundled?  From
> the org.drools.runtime I am wondering if I should be instead
> implemeting org,drools.runtime.Calendars?
Drools doesn't "use" quartz scheduler. What we do allow is a quartz 
calender to be used. We have our own calendar interface, but provide an 
adapter so our scheduler can work with a quartz calendar.

Mark
>
> By the way, often in Drools I see an API to get from a list or hashmap
> of something (e.g., calendars, working memories,
> workingmemoryinstances).  However, if you have only one of the things
> (like one calendar or one session) what should I pass to the
> .get(<string>) method to access the one item?
>
> Also, the source code includes SCenarioRunner.java which seems to be
> no longer valid.
>
> Thanks.
>
> David
>
>
> On Mon, Jun 6, 2011 at 10:41 AM, Mark Proctor<mproctor at codehaus.org>  wrote:
>> On 06/06/2011 15:32, drdaveg at gmail.com wrote:
>>> Mark,
>>>
>>> I thought I had submitted a follow-up to this, but perhaps not.  I'm
>>> sending this to you instead of the list to avoid generating excess traffic.
>>>
>>> I looked at CR1 and am going to look at it's source today.  But neither
>>> the examples in the Drools PDF or Quartz look compatible for a clock that
>>> would work with date-expires and date-effective of rules.  Quartz looks
>>> great for rules, processes and events that run on heatbeats (e.g., a cron
>>> schedule) but it looks so foreign for use as a system clock I wonder if
>>> date-expires and date-effective have been tested with the clock?  Might you
>>> have an example or JUnit for this setup?
>>>
>>> I will look for one in Guvnor's source code today, where rule testing with
>>> a simulated date should have a JUnit.
>> This is in Rule and shows how effective dating works.
>>             Calendar now = Calendar.getInstance();
>>             now.setTimeInMillis(
>> workingMemory.getSessionClock().getCurrentTime() );
>>
>>             if ( this.dateEffective != null&&  this.dateExpires != null ) {
>>                 return (now.after( this.dateEffective )&&  now.before(
>> this.dateExpires ));
>>             } else if ( this.dateEffective != null ) {
>>                 return (now.after( this.dateEffective ));
>>             } else {
>>                 return (now.before( this.dateExpires ));
>>             }
>>
>> Unit testing should use the Pseduo clock, for the session clock, where you
>> can manually set the time.
>>
>> Mark
>>> Thanks!
>>>
>>> David Goldstein
>>>
>>> <quote author='Mark Proctor'>
>>> On 01/06/2011 21:37, drdaveg wrote:
>>>> A common issue that I am looking into is setting the execution date to
>>>> test
>>>> future or legacy rules (i.e., with dates that are not the system date.)
>>>>   A
>>>> number of users have posted about TimeMachine, TimeServices and the
>>>> perils
>>>> of setting the system date - but a JIRA lists TimeMachine as being remove
>>>> and TimeServices doesn't look like it has a setter for the execution
>>>> time.
>>>>
>>>> What is the API for simulating the date to be compared against effective
>>>> and
>>>> expiration dates of rules that can be used by stateful sessions?
>>> in upcoming drools 5.2, see CR1. TimeMachine was removed. Everything
>>> should now work around the session clock, where it can use the system
>>> clock or a pseudo clock.
>>>
>>> Mark
>>>> --
>>>> View this message in context:
>>>>
>>>> http://drools.46999.n3.nabble.com/TimerService-vs-TimeMachine-and-date-effective-tp3012560p3012560.html
>>>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>> </quote>
>>> Quoted from:
>>>
>>> http://drools.46999.n3.nabble.com/TimerService-vs-TimeMachine-and-date-effective-tp3012560p3012634.html
>>>
>>>
>>
>>
>





More information about the rules-users mailing list