<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Look at the interval timer test here from line 254 onwards, and the
    subsequent cron tests:<br>
<a class="moz-txt-link-freetext" href="https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/TimerAndCalendarTest.java#L254">https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/TimerAndCalendarTest.java#L254</a><br>
    <br>
    <br>
    On 13/10/2009 00:32, Ben Scott wrote:
    <blockquote
cite="mid:200910122332.n9CNW3wh009804@lists01.dmz-a.mwc.hst.phx2.redhat.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <meta name="Generator" content="Microsoft Exchange Server">
      <!-- converted from rtf -->
      <style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
      <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.<o:p></o:p></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">
          <o:p></o:p></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&lt;Boolean&gt; {<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>&nbsp;</div>
        <div><font face="Arial, sans-serif">&nbsp;</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.<o:p></o:p></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.<o:p></o:p></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"><o:p></o:p></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.<o:p></o:p></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"><o:p></o:p></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.<o:p></o:p></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"><o:p></o:p></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"><o:p></o:p></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>
          <o:p></o:p></font></span>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>