You are pretty close:<br>entryPoints["<span style="color: rgb(51, 102, 255);"><span style="color: rgb(255, 0, 0);">ob1 stream</span></span>"].insert(mre);<br><br>Try with that.<br><br><div class="gmail_quote">2009/8/16 Justin King <span dir="ltr"><<a href="mailto:justin.matthew.king@gmail.com">justin.matthew.king@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Everyone,<br><br>I'm aware that in Drools you can use 'insert()' in the 'then' part of a rule to insert a new fact into the memory, meaning more rules may be fired based on the addition of this new fact. I wish to do a similar thing, but I wish to insert the fact into a specific entry point. My current rule code to do this is:<br>
<br><span style="color: rgb(51, 102, 255);">rule "Allow message buyBook"</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">no-loop true</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> when</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"> $event : MessageRecievedEvent(operationName == "buyBook") from entry-point "t1 stream"</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> then</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"> MessageRecievedEvent mre = new MessageRecievedEvent();</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> mre.setOperationName("sellBook");</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"> StatefulKnowledgeSession session = kcontext.getKnowledgeRuntime().getKnowledgeBase().newStatefulKnowledgeSession();</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> WorkingMemoryEntryPoint obStream = session.getWorkingMemoryEntryPoint("ob1 stream");</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"> obStream.insert(mre);</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> session.fireAllRules();</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">end</span><br style="color: rgb(51, 102, 255);"><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">rule "ob1"</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">no-loop true</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"> when</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> $event : MessageRecievedEvent(operationName == "sellBook") from entry-point "ob1 stream"</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);"> then</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> System.out.println("executed");</span><br style="color: rgb(51, 102, 255);"><span style="color: rgb(51, 102, 255);">end</span><br><br>Which is pretty hideous, but it does work, causing the second rule to fire after the first one. What I would like is something like:<br>
<br><span style="color: rgb(51, 102, 255);">rule "Allow message buyBook"</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">no-loop true</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> when</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> $event : MessageRecievedEvent(operationName == "buyBook") from entry-point "t1 stream"</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> then</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> MessageRecievedEvent mre = new MessageRecievedEvent();</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> mre.setOperationName("sellBook");</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> <span style="color: rgb(255, 0, 0);">insert(mre, "ob1 stream")</span></span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">end</span><br style="color: rgb(51, 102, 255);">
<br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">rule "ob1"</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">no-loop true</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> when</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> $event : MessageRecievedEvent(operationName == "sellBook") from entry-point "ob1 stream"</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> then</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> System.out.println("executed");</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">end</span><br><br><font color="#000000">Is something like this possible or will I have to write a function to do it? I'm also a bit concerned about the performance hit of creating a whole new StatefulKnowledgeSession to fire the second rule, I'd like to just use the current one.<br>
<br>Thanks,<br><br>Justin<br></font>
<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>
<br></blockquote></div><br><br clear="all"><br>-- <br> - <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br> - <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br> - Salatino "Salaboy" Mauricio -<br>