Re: [rules-users] Temporal reasoning with external persistence not working
First of all, don't use automated time stamping of events; add a field carrying the (original) event time. I think you could also run the session in CLOUD mode. Also, it may not be advisable to pull in facts and reason over them in the same rule. Perhaps retrieval and proper insertion of facts should even be coded in Java, kept separate from the rule logic. Much depends on the required use cases for running those multiple sessions, and how canned events relate to other data. -W On 13 July 2011 02:13, rp2 wrote: > > Wolfgang Laun-2 wrote: > > > > The example does not use events, as in @role(event). You can maintain > > a value of type java.util.Date in your hibernated facts, but don't make > > them events the way you do. > > > > > It is important for me to use temporal reasoning and CEP, and hence HAD to > define these as @events. > > In addition I wanted to load and persist these events from/in a custom non > JPA compliant key-value store because I will be running multiple instances > of drools as opposed to only one server. Therefore relying on RAM based > working memory is not enough. > > What would be your suggestion in that regard? > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persistence-not-working-tp3158399p3164267.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Temporal reasoning with external persistence not working
Wolfgang Laun-2 wrote: > > The example does not use events, as in @role(event). You can maintain > a value of type java.util.Date in your hibernated facts, but don't make > them events the way you do. > > It is important for me to use temporal reasoning and CEP, and hence HAD to define these as @events. In addition I wanted to load and persist these events from/in a custom non JPA compliant key-value store because I will be running multiple instances of drools as opposed to only one server. Therefore relying on RAM based working memory is not enough. What would be your suggestion in that regard? -- View this message in context: http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persistence-not-working-tp3158399p3164267.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Temporal reasoning with external persistence not working
On 12 July 2011 19:47, rp2 wrote: > Thanks. > Basically I am trying to retrieve (and store) events from an external store > like in > http://magazine.redhat.com/2008/07/11/jboss-drools-meets-hibernate/ > expect that the backing store in not a relational db but a custom key-value > store. > > This example also does not show the facts/events being inserted. Is this > incorrect? > The example does not use events, as in @role(event). You can maintain a value of type java.util.Date in your hibernated facts, but don't make them events the way you do. -W > > All it does is > ... ... > workingMemory.setGlobal("hibernateSession", session); // sets a hibernate > session > workingMemory.fireAllRules(); > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persistence-not-working-tp3158399p3163303.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Temporal reasoning with external persistence not working
Thanks. Basically I am trying to retrieve (and store) events from an external store like in http://magazine.redhat.com/2008/07/11/jboss-drools-meets-hibernate/ expect that the backing store in not a relational db but a custom key-value store. This example also does not show the facts/events being inserted. Is this incorrect? All it does is ... ... workingMemory.setGlobal("hibernateSession", session); // sets a hibernate session workingMemory.fireAllRules(); -- View this message in context: http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persistence-not-working-tp3158399p3163303.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Temporal reasoning with external persistence not working
Objects produced by a "from" clause that haven't been inserted into Working Memory previously are not facts, let alone events. As the presented code shows, the timestamp of event User should be set by Drools when the fact is inserted. Frist, with "from" it isn't inserted at all, and second, if it were inserted, what timestamp would it receive - the time it was taken from session.getUserByIndex(0)? Not knowing why you do what you do it's difficult to suggest alternatives. -W On 12 July 2011 18:46, rp2 wrote: > Could someone please provide an answer? > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persistence-not-working-tp3158399p3163063.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Temporal reasoning with external persistence not working
Could someone please provide an answer? -- View this message in context: http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persistence-not-working-tp3158399p3163063.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Temporal reasoning with external persistence not working
I am trying to use an external storage for loading and persisting objects. But when I try a set a temporal reasoning rule it start to fail. The rule, test code and exception are given below. Please help // rules file package foo.externalwm; global foo.ExternalStorage session; import foo.externalwm.YUser import foo.externalwm.Test declare User @role(event) end declare Contest @role(event) end rule "test" dialect "java" when $c1:Contest() from session.getContestByName("Contest1") User(this after[0,3m] $c1) from session.getUserByIndex(0) then System.out.println("rule fired"); end // code public class Test { public static void main(String[] args) throws Exception { KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); config.setOption( EventProcessingOption.STREAM ); KnowledgeBase k = init(); // read and compile rules done here final StatefulKnowledgeSession ksession = k.newStatefulKnowledgeSession(); ExternalStorage session = new ExternalStorage(); ksession.setGlobal("session", session); ksession.fireAllRules(); } ***EXCEPTION Exception in thread "main" org.drools.RuntimeDroolsException: Unexpected exception executing action org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction@669a4cb at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:996) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:730) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:699) at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218) at foo.externalwm.Test.main(Test.java:55) Caused by: java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be cast to org.drools.common.EventFactHandle at org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:332) at org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110) at org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:111) at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:127) at org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274) at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:137) at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189) at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64) at org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279) at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:137) at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189) at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138) at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:141) at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59) at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185) at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:143) at org.drools.reteoo.Rete.assertObject(Rete.java:107) at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:260) at org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:343) at org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:994) ... 4 more -- View this message in context: http://drools.46999.n3.nabble.com/Temporal-reasoning-with-external-persistence-not-working-tp3158399p3158399.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users