Re: [rules-users] Drools 5 PseudoClock with StatelessKnowledgeSession

2011-09-30 Thread Edson Tirelli
   I think there might be a conceptual problem here. Stateless sessions are
supposed to take a snapshot of facts (and/or events) and run all rules for
them and dispose the session. Since it is a snapshot, there is no concept of
time flow during the execution and so it can only run in the equivalent of
CLOUD mode for stateful sessions. That is why no session clock is provided
for stateless sessions.

   In order to use the SessionClock, one needs to use a stateful session
configured in STREAM mode.

   I believe we can add features in the future like the ability to run a
session with a given reference time, even if it does not involve time flow,
but that is not there. Also, since date-effective and date-expiration are
really old features, from the drools 2-3 versions, and they have quite a
number of limitations, you are probably better using enabled expressions
than using those attributes.

   Edson


2011/9/29 Mark Proctor mproc...@codehaus.org

  Look at the interval timer test here from line 254 onwards, and the
 subsequent cron tests:

 https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/TimerAndCalendarTest.java#L254



 On 13/10/2009 00:32, Ben Scott wrote:

   Note: This e-mail is subject to the disclaimer contained at the bottom
 of this message.

  --
 
 I'm wanting to use the date-effective and date-expiry rule metadata to add
 date specific rule variants within my app. To test these I was planning on
 using the pseudo clock and setting the expected date prior to executing the
 rules within a StatelessKnowledgeSession. I can set the clock easily enough,
 but can't understand why the getSessionClock() method is missing? It's on
 the StatefulKnowledgeSession, but not on the Stateless.
 I'm initialising the session like this:
 SessionConfiguration sessionConfiguration = new SessionConfiguration();
 sessionConfiguration.setClockType( ClockType.PSEUDO_CLOCK );
 StatelessKnowledgeSession session =
 _testKnowledgeBase.newStatelessKnowledgeSession(sessionConfiguration);
 The only thing I could think of to set the pseudo clock was to write a
 command something like:
 private static class SetPseudoClockCommand implements
 org.drools.process.command.CommandBoolean {
 public Boolean execute(ReteooWorkingMemory session) {
 // Set the clock to the current date
 pseudoSessionClock.advanceTime(new DateTime().getMillis(),
 TimeUnit.MILLISECONDS);
 // Add a couple of days
 pseudoSessionClock.advanceTime(2, TimeUnit.DAYS);
 return true;
 }
 }
 But this doesn't appear to take any effect whilst rules are running.
 Is there another way to get programmatic access to the session clock, or
 some better way of changing the underlying date prior to rule execution?
 Ben.


  --

 The information transmitted in this message and its attachments (if any) is
 intended only for the person or entity to which it is addressed.

 The message may contain confidential and/or privileged material. Any
 review, retransmission, dissemination or other use of, or taking of any
 action in reliance upon this information, by persons or entities other than
 the intended recipient is prohibited.

 

 If you have received this in error, please contact the sender and delete
 this e-mail and associated material from any computer.

 

 The intended recipient of this e-mail may only use, reproduce, disclose or
 distribute the information contained in this e-mail and any attached files,
 with the permission of the sender.

 

 This message has been scanned for viruses with Symantec Scan Engine and
 cleared by MailMarshal.

 

  --
 

 ___
 rules-users mailing 
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools 5 PseudoClock with StatelessKnowledgeSession

2011-09-29 Thread sanjuk72
Hi,

I wanted to know if you found any solution to this. I have a same issue, 
I need to run the legagcy rules and for that need to change the date that
rules have using the date-effective and date-expiry.

I was thinking of using this functionality, but it seems not available with
Stateless Sessions.

Please let me know

thanks

--
View this message in context: 
http://drools.46999.n3.nabble.com/Drools-5-PseudoClock-with-StatelessKnowledgeSession-tp62084p3380930.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools 5 PseudoClock with StatelessKnowledgeSession

2011-09-29 Thread Mark Proctor
Look at the interval timer test here from line 254 onwards, and the 
subsequent cron tests:

https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/TimerAndCalendarTest.java#L254


On 13/10/2009 00:32, Ben Scott wrote:


Note: This e-mail is subject to the disclaimer contained at the bottom 
of this message.



I'm wanting to use the date-effective and date-expiry rule metadata to 
add date specific rule variants within my app. To test these I was 
planning on using the pseudo clock and setting the expected date prior 
to executing the rules within a StatelessKnowledgeSession. I can set 
the clock easily enough, but can't understand why the 
getSessionClock() method is missing? It's on the 
StatefulKnowledgeSession, but not on the Stateless.

I'm initialising the session like this:
SessionConfiguration sessionConfiguration = new SessionConfiguration();
sessionConfiguration.setClockType( ClockType.PSEUDO_CLOCK );
StatelessKnowledgeSession session = 
_testKnowledgeBase.newStatelessKnowledgeSession(sessionConfiguration);
The only thing I could think of to set the pseudo clock was to write a 
command something like:
private static class SetPseudoClockCommand implements 
org.drools.process.command.CommandBoolean {

public Boolean execute(ReteooWorkingMemory session) {
// Set the clock to the current date
pseudoSessionClock.advanceTime(new DateTime().getMillis(), 
TimeUnit.MILLISECONDS);

// Add a couple of days
pseudoSessionClock.advanceTime(2, TimeUnit.DAYS);
return true;
}
}
But this doesn't appear to take any effect whilst rules are running.
Is there another way to get programmatic access to the session clock, 
or some better way of changing the underlying date prior to rule 
execution?

Ben.


The information transmitted in this message and its attachments (if 
any) is intended only for the person or entity to which it is addressed.


The message may contain confidential and/or privileged material. Any 
review, retransmission, dissemination or other use of, or taking of 
any action in reliance upon this information, by persons or entities 
other than the intended recipient is prohibited.


If you have received this in error, please contact the sender and 
delete this e-mail and associated material from any computer.


The intended recipient of this e-mail may only use, reproduce, 
disclose or distribute the information contained in this e-mail and 
any attached files, with the permission of the sender.


This message has been scanned for viruses with Symantec Scan Engine 
and cleared by MailMarshal.





___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users