<div><br></div> 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.<div>
<br></div><div> In order to use the SessionClock, one needs to use a stateful session configured in STREAM mode.</div><div><br></div><div> 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.</div>
<div><br></div><div> Edson</div><div><div> <br><br><div class="gmail_quote">2011/9/29 Mark Proctor <span dir="ltr"><<a href="mailto:mproctor@codehaus.org" target="_blank">mproctor@codehaus.org</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
Look at the interval timer test here from line 254 onwards, and the
subsequent cron tests:<br>
<a href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/TimerAndCalendarTest.java#L254" target="_blank">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/TimerAndCalendarTest.java#L254</a><div>
<div></div><div><br>
<br>
<br>
On 13/10/2009 00:32, Ben Scott wrote:
</div></div><blockquote type="cite"><div><div></div><div>
<font face="Times New Roman, serif" size="2">
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify"><span style="font-size:8pt;color:red;font-family:Arial"></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify"><span style="font-size:8pt;color:red;font-family:Arial"></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1">Note: This e-mail is subject to the
disclaimer contained at the bottom of this message.<u></u><u></u></font></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1">
</font></span></p>
<hr><font size="1">
<u></u><u></u></font>
<div style="margin-top:5pt;margin-bottom:5pt">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. </div>
<div style="margin-top:5pt;margin-bottom:5pt">I'm
initialising the session like this:<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">SessionConfiguration
sessionConfiguration = new SessionConfiguration();<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">sessionConfiguration.setClockType(
ClockType.PSEUDO_CLOCK );<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">StatelessKnowledgeSession
session =
_testKnowledgeBase.newStatelessKnowledgeSession(sessionConfiguration);
</div>
<div style="margin-top:5pt;margin-bottom:5pt">The only
thing I could think of to set the pseudo clock was to write a
command something like:<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">private
static class SetPseudoClockCommand implements
org.drools.process.command.Command<Boolean> {<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">public
Boolean execute(ReteooWorkingMemory session) {<font size="3">
</font></div>
<div style="margin-top:5pt;margin-bottom:5pt">// Set the
clock to the current date<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">pseudoSessionClock.advanceTime(new
DateTime().getMillis(), TimeUnit.MILLISECONDS);<font size="3">
</font></div>
<div style="margin-top:5pt;margin-bottom:5pt">// Add a
couple of days<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">pseudoSessionClock.advanceTime(2,
TimeUnit.DAYS); </div>
<div style="margin-top:5pt;margin-bottom:5pt">return true;<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">}<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">}<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">But this
doesn't appear to take any effect whilst rules are running.<font size="3"> </font></div>
<div style="margin-top:5pt;margin-bottom:5pt">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? </div>
<div style="margin-top:5pt;margin-bottom:5pt">Ben. </div>
<div> </div>
<div><font face="Arial, sans-serif"> </font></div>
</font>
<span style="font-size:8pt;color:red;font-family:Arial">
<hr>
</span>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1">The information transmitted
in this message and its attachments (if any) is intended
only for the person or entity to which it is addressed.<u></u><u></u></font></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1">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.<u></u><u></u></font></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1">If you have received this
in error, please contact the sender and delete this e-mail
and associated material from any computer.<u></u><u></u></font></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1">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.<u></u><u></u></font></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1">This message has been
scanned for viruses with Symantec Scan Engine and cleared by
MailMarshal.</font></span></p>
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left"><span style="font-size:8pt;color:red;font-family:Arial"><font size="1"><u></u><u></u></font></span></p>
<span style="font-size:8pt;color:red;font-family:Arial"><font size="1">
<p class="MsoNormal" style="margin:0cm 0cm 0pt;text-align:justify" align="left">
</p>
<hr>
<u></u><u></u></font></span>
<br>
<fieldset></fieldset>
<br>
</div></div><div><pre>_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</div></blockquote>
<br>
</div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</div>
</div>