<div dir="ltr">I&#39;m disposing after use because if i&#39;m not the working memory is not empty between 2 calls right ? And I am saying that I&#39;m using them as a pool because I have 5 sessions that could be used at the same time, which is impossible if I declare only one.<div>
<br><div>If you have recommandation for my use case, please tell me as I found nothing in the doc about this.</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-13 22:42 GMT+02:00 Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org" target="_blank">mproctor@codehaus.org</a>&gt;</span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">as it says in the docs. we&rsquo;ve designed things to put in foundations for future multi-threaded exploitation, but there is nothing there now.<div>
<br></div><div>The &nbsp;example code doesn&rsquo;t make too much sense to me. As you are saying you are using them as a pool, but you are disposing after use.</div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span><div>
<span class="HOEnZb"><font color="#888888">Mark</font></span><div><div class="h5"><br><div><div>On 11 Apr 2014, at 08:48, Mercier Jonathan &lt;<a href="mailto:jmercier@genoscope.cns.fr" target="_blank">jmercier@genoscope.cns.fr</a>&gt; wrote:</div>
<br><blockquote type="cite">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Le 09/04/2014 11:20, Maxime Falaize a
      écrit&nbsp;:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">I confirm that the multithreaded rules evaluation
        is not currently supported. See <a href="https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/RuleBaseConfiguration.java#L683" target="_blank">https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/core/RuleBaseConfiguration.java#L683</a><br>

      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">2014-04-07 12:27 GMT+02:00 Maxime
          Falaize <span dir="ltr">&lt;<a href="mailto:maxime.falaize@gmail.com" target="_blank">maxime.falaize@gmail.com</a>&gt;</span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">I&#39;m sorry but I don&#39;t understand what you are
              talking about. In this article, there is nothing about
              multithreaded rules evaluation. It just says that the
              Phreak algorithm is designed for thread safety and <b>future</b>
              multicore processors exploitation. It doesn&#39;t mean that it
              is already multithreaded. Moreover I tested my
              appliciation with and without multithreaded sessions (I am
              using Drools 6.0.1.Final) and I noted a faster execution
              in the multithreaded one.</div>
            <div class="gmail_extra"><br>
              <br>
              <div class="gmail_quote">2014-04-04 13:53 GMT+02:00
                jmercier <span dir="ltr">&lt;<a href="mailto:jmercier@genoscope.cns.fr" target="_blank">jmercier@genoscope.cns.fr</a>&gt;</span>:
                <div>
                  <div>
                    <br>
                    <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      Le 04/03/2014 09:55, Maxime Falaize a écrit&nbsp;:<br>
                      <div>
                        <div>&gt; Hello,<br>
                          &gt;<br>
                          &gt; I want to ask you if it is a good
                          practive to pool stateful sessions<br>
                          &gt; for a specific ruleset to improve the
                          execution performance.<br>
                          &gt; Actually in my application I execute my
                          rules by calling SOAP<br>
                          &gt; webservice. For performance purpose, I
                          test multithreaded calls to my<br>
                          &gt; webservice and I noted that when I pool
                          sessions in the server side,<br>
                          &gt; it improves the performance a lot.<br>
                          &gt;<br>
                          &gt; To pool sessions, I just declare multiple
                          ksession tag in my<br>
                          &gt; kmodule.xml :<br>
                          &gt;<br>
                          &gt; &lt;kbase name=&quot;KBase&quot;
                          packages=&quot;com.example.*&quot;&gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ksession
                          name=&quot;KSession1&quot;/&gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ksession
                          name=&quot;KSession2&quot;/&gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ksession
                          name=&quot;KSession3&quot;/&gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ksession
                          name=&quot;KSession4&quot;/&gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ksession
                          name=&quot;KSession5&quot;/&gt;<br>
                          &gt; &nbsp;&lt;/kbase&gt;<br>
                          &gt;<br>
                          &gt; In my spring webservice endpoint I just
                          put that code to handle the<br>
                          &gt; pool :<br>
                          &gt;<br>
                          &gt; @Endpoint<br>
                          &gt; public class ExampleEndpoint implements
                          InitializingBean {<br>
                          &gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp; @Autowired<br>
                          &gt; &nbsp;&nbsp;&nbsp; private ExampleRuleService
                          ruleService;<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp; private Map&lt;Integer, Boolean&gt;
                          isRunningMap = new<br>
                          &gt; HashMap&lt;Integer, Boolean&gt;();<br>
                          &gt; &nbsp;&nbsp;&nbsp; private static final int
                          NB_POOL_SESSIONS = 5;<br>
                          &gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp; @PayloadRoot(localPart =
                          &quot;com.example.ExampleRequest&quot;)<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp; @ResponsePayload<br>
                          &gt; &nbsp;&nbsp;&nbsp; public ExampleResponse handleRequest(<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @RequestPayload
                          ExampleRequest request) throws<br>
                          &gt; InterruptedException {<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; KieServices ks =
                          KieServices.Factory.get();<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; KieContainer kc =
                          ks.getKieClasspathContainer();<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; while (true) {<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i = 0; i &lt;
                          NB_POOL_SESSIONS; i++) {<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; boolean run = false;<br>
                          &gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; synchronized
                          (isRunningMap) {<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if
                          (!isRunningMap.get(i)) {<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                          isRunningMap.put(i, true);<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; run = true;<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                          &gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (run) {<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; KieSession ksession =
                          kc.newKieSession(&quot;KSession&quot;<br>
                          &gt; + (i + 1));<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExampleResponse
                          response =<br>
                          &gt; ruleService.run(ksession, request);<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ksession.dispose();<br>
                          &gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; isRunningMap.put(i,
                          false);<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return response;<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Thread.sleep(100);<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                          &gt; &nbsp;&nbsp;&nbsp; }<br>
                          &gt;<br>
                          &gt; &nbsp;&nbsp;&nbsp; public void afterPropertiesSet()
                          throws Exception {<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i = 1; i &lt;=
                          NB_POOL_SESSIONS; i++) {<br>
                          &gt; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; isRunningMap.put((i - 1),
                          false);<br>
                          &gt; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                          &gt; &nbsp;&nbsp;&nbsp; }<br>
                          &gt;<br>
                          &gt; }<br>
                          &gt;<br>
                          &gt; It works well because in my benchmark I
                          improve 5 times the<br>
                          &gt; performance (as I have 5 different
                          threads) but I wondered if it is a<br>
                          &gt; good practice and if it does not hide any
                          issues that I could have in<br>
                          &gt; the future.<br>
                          &gt;<br>
                          &gt; Thanks for your help.<br>
                          &gt;<br>
                          &gt; --<br>
                          &gt; Maxime FALAIZE<br>
                        </div>
                      </div>
                      &gt;
                      _______________________________________________<br>
                      &gt; rules-users mailing list<br>
                      &gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
                      &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
                      <br>
                      <br>
                      Hi maxime,<br>
                      <br>
                      I do not remember if use drools 6 or drools 5. If
                      you using drools 6.<br>
                      Phreaks algorithm use multi threading according to
                      use &#39;from<br>
                      accummulate&#39; far i understand here:<br>
                      <a href="http://planet.jboss.org/post/drools_6_performance_with_the_phreak_algorithm" target="_blank">http://planet.jboss.org/post/drools_6_performance_with_the_phreak_algorithm</a><br>
                      <br>
                      Instead to put a thread by ksession here rules
                      evaluation are<br>
                      multi-threaded.<br>
                      <br>
                      <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></blockquote>
                  </div>
                </div>
              </div>
              <span><font color="#888888"><br>
                  <br clear="all">
                  <div><br>
                  </div>
                  -- <br>
                  Maxime FALAIZE
                </font></span></div>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        Maxime FALAIZE
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <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>
    </blockquote>
    <br>
    Ah yes. Maybe Mark Proktor could tell&nbsp; some information about this<br>
  </div>

_______________________________________________<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></blockquote>
</div><br></div></div></div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">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></blockquote></div><br><br clear="all"><div><br></div>-- <br>Maxime FALAIZE
</div>