Hi Everyone, 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:
rule "Allow message buyBook" no-loop true when $event : MessageRecievedEvent(operationName == "buyBook") from entry-point "t1 stream" then MessageRecievedEvent mre = new MessageRecievedEvent(); mre.setOperationName("sellBook"); StatefulKnowledgeSession session = kcontext.getKnowledgeRuntime().getKnowledgeBase().newStatefulKnowledgeSession(); WorkingMemoryEntryPoint obStream = session.getWorkingMemoryEntryPoint("ob1 stream"); obStream.insert(mre); session.fireAllRules(); end rule "ob1" no-loop true when $event : MessageRecievedEvent(operationName == "sellBook") from entry-point "ob1 stream" then System.out.println("executed"); end 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: rule "Allow message buyBook" no-loop true when $event : MessageRecievedEvent(operationName == "buyBook") from entry-point "t1 stream" then MessageRecievedEvent mre = new MessageRecievedEvent(); mre.setOperationName("sellBook"); insert(mre, "ob1 stream") end rule "ob1" no-loop true when $event : MessageRecievedEvent(operationName == "sellBook") from entry-point "ob1 stream" then System.out.println("executed"); end 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. Thanks, Justin
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users