Hi Edson!<br><br> as I&#39;ve already mentioned I&#39;ve modified the sample so, if you get the StockTick sample and replace the Main class this will run fine.<br> The sample shuts down fine but as I saw it sets the JFrame uses frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); which in turn makes the trick.<br>
<br> Below the code of my modified main class:<br><br>package org.drools.examples.broker;<br><br><br>import org.drools.KnowledgeBase;<br>import org.drools.KnowledgeBaseConfiguration;<br>import org.drools.KnowledgeBaseFactory;<br>
import org.drools.builder.KnowledgeBuilder;<br>import org.drools.builder.KnowledgeBuilderFactory;<br>import org.drools.builder.ResourceType;<br>import org.drools.conf.EventProcessingOption;<br>import org.drools.examples.broker.model.Company;<br>
import org.drools.examples.broker.model.CompanyRegistry;<br>import org.drools.examples.broker.model.StockTick;<br>import org.drools.io.ResourceFactory;<br>import org.drools.runtime.StatefulKnowledgeSession;<br>import org.drools.runtime.rule.WorkingMemoryEntryPoint;<br>
<br>public class Main {<br>    private static final String RULES_FILE = &quot;/broker.drl&quot;;<br>    static StatefulKnowledgeSession session;<br>    static WorkingMemoryEntryPoint tickStream;<br><br>    /**<br>     * @param args<br>
     */<br>    public static void main(String[] args) throws Exception {<br>        // set up and show main window<br>        <br>        CompanyRegistry companies = new CompanyRegistry();<br>        <br>        KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br>
        try {<br>            builder.add( ResourceFactory.newInputStreamResource( Main.class.getResourceAsStream( RULES_FILE ) ),<br>                         ResourceType.DRL);<br>        } catch ( Exception e ) {<br>            e.printStackTrace();<br>
        }<br>        if( builder.hasErrors() ) {<br>            System.err.println(builder.getErrors());<br>            System.exit( 0 );<br>        }<br><br>        KnowledgeBaseConfiguration conf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();<br>
        conf.setOption( EventProcessingOption.STREAM );<br>        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( conf );<br>        kbase.addKnowledgePackages( builder.getKnowledgePackages() );<br>        <br>
        session = kbase.newStatefulKnowledgeSession();<br><br>        session.setGlobal( &quot;services&quot;, new BrokerServices() {<br>            public void log(String message) {<br>                System.out.println(message);                <br>
            }<br>        });<br><br>        for( Company company : companies.getCompanies() ) {<br>            session.insert( company );<br>        }<br>        session.fireAllRules();<br>        <br>        tickStream = session.getWorkingMemoryEntryPoint( &quot;StockTick stream&quot; );<br>
 <br>        for (int i=10;i&gt;0;i--) {<br>            tickStream.insert(new StockTick(&quot;RHT&quot;, i*10, System.currentTimeMillis()));<br>            session.getAgenda().getAgendaGroup( &quot;evaluation&quot; ).setFocus();<br>
            session.fireAllRules();<br>        }<br>        session.dispose();<br>        session.halt();<br>        System.out.println(&quot;Still running...&quot;);<br>    }<br>    <br>}<br><br><br>regards,<br>Rafael Ribeiro<br>
<br><div class="gmail_quote">2009/7/16 Edson Tirelli <span dir="ltr">&lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>   Hi Rafael,<br><br>   Are you setting the MultithreadEvaluation option or is this using default options? Do you have an example code that shows this behavior?<br><br>   Thanks,<br>     Edson<br><br><div class="gmail_quote">

2009/7/16 Rafael Ribeiro <span dir="ltr">&lt;<a href="mailto:rafaelri@gmail.com" target="_blank">rafaelri@gmail.com</a>&gt;</span><div class="im"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
Hi all,<br>
<br>
 I&#39;ve downloaded Drools fusion sample and started to make some changes to<br>
the code (first of all wipe out the UI so I can test it easier).<br>
 I tried to get to a minimal set so I can run a console main class and see<br>
what happens but I am facing a strange behaviour.<br>
 As soon as I start pushing events into the WorkingMemoryEntryPoint<br>
(&quot;StockTick stream&quot;) a Thread - not daemonized since it blocks shutdown from<br>
ending - is spawned and this prevents my JVM from shutting down (obviously<br>
if I call System.exit(0) it will but I am avoiding this).<br>
 I&#39;ve tried both to halt and dispose the session that this entry point<br>
belongs but with no success. Does anyone know how could I get rid of this<br>
thread?<br>
<br>
best regards,<br>
<font color="#888888">--</font><br>
</blockquote></div></div><br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="http://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">http://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>