<br> Declare your fact type with @role( event ).<br><br><div class="gmail_quote">2009/4/2 Nestor Tarin Burriel <span dir="ltr"><<a href="mailto:nestabur@gmail.com">nestabur@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;">
And how can I create events from guvnor?<br><br><div class="gmail_quote">2009/4/2 Edson Tirelli <span dir="ltr"><<a href="mailto:tirelli@post.com" target="_blank">tirelli@post.com</a>></span><div><div></div><div class="h5">
<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> Need to fix the error message, but it seems you are trying to use the sliding window on regular facts... sliding window only makes sense for events...<br><br> Also, the property you are using to set the event processing mode seems wrong. Check here:<div>
<br>
<br><a href="https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-fusion/html/ch02.html#d0e1067" target="_blank">https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-fusion/html/ch02.html#d0e1067</a><br>
<br></div> []s<br> Edson<br><br><div class="gmail_quote">2009/4/2 nestabur <span dir="ltr"><<a href="mailto:nestabur@gmail.com" target="_blank">nestabur@gmail.com</a>></span><div><div></div><div><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Hi All,<br>
<br>
I'm trying to use sliding windows with guvnor, I deploy the package in my<br>
rule engine as:<br>
<br>
Properties props = new Properties();<br>
props.put("url", rulePackagePath);<br>
props.put("eventProcessingMode", "stream");<br>
<br>
agent = RuleAgent.newRuleAgent(props);<br>
session = agent.getRuleBase().newStatefulSession();<br>
<br>
When I insert a fact into the working memory as:<br>
session.insert(fact);<br>
session.fireAllRules();<br>
<br>
I get the following error:<br>
<br>
Exception while processing message: java.lang.ClassCastException:<br>
org.drools.common.DefaultFactHandle cannot be cast to<br>
org.drools.common.EventFactHandle<br>
java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be<br>
cast to org.drools.common.EventFactHandle<br>
at<br>
org.drools.rule.SlidingTimeWindow.updateNextExpiration(SlidingTimeWindow.java:192)<br>
at<br>
org.drools.rule.SlidingTimeWindow.assertRightTuple(SlidingTimeWindow.java:119)<br>
at<br>
org.drools.rule.BehaviorManager.assertRightTuple(BehaviorManager.java:87)<br>
at org.drools.reteoo.ExistsNode.assertObject(ExistsNode.java:172)<br>
at<br>
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:366)<br>
at<br>
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:349)<br>
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:147)<br>
at<br>
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)<br>
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:184)<br>
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)<br>
at<br>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1066)<br>
at<br>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1022)<br>
at<br>
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:810)<br>
at<br>
com.s2grupo.triton.service.impl.CorrelatorServiceImpl.insertFact(CorrelatorServiceImpl.java:64)<br>
at<br>
com.s2grupo.triton.jms.impl.JmsMessageListenerImpl.onMessage(JmsMessageListenerImpl.java:67)<br>
at<br>
org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1021)<br>
at<br>
org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:122)<br>
at<br>
org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:192)<br>
at<br>
org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)<br>
at<br>
org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)<br>
at<br>
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br>
at<br>
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br>
at java.lang.Thread.run(Thread.java:619)<br>
<br>
What I'm missing? Is it a bug? I'm using the 5.0.0.SNAPSHOT version of<br>
drools.<br>
<br>
Thanks,<br>
<br>
NEStor<br>
<div><div></div><div><br>
<br>
ober0n wrote:<br>
><br>
> Hi Ed, thanks for the quick reply, I will try the temporal constraints as<br>
> well.<br>
><br>
> I haven't completed my testing yet but the sliding windows seems to be<br>
> working. Thanks!<br>
><br>
> I am getting a strange problem of my program hanging. It gets all the way<br>
> past my "dispose()" of the StatefulKnowledgeSession and closing the<br>
> session logger and to the end of my main(). Then it just sits there. I'm<br>
> thinking it's a bug in my rules but wanted to make sure this wasn't a<br>
> feature of Streams (maybe some thread kicked off to accept facts or<br>
> something).<br>
><br>
> If you could just confirm nothing in Drools fusion is supposed to continue<br>
> running, that would be great.<br>
><br>
> Here are the significant snippets of my code:<br>
> ...<br>
> WorkingMemoryEntryPoint eventStream =<br>
> ksession.getWorkingMemoryEntryPoint( "EventStream" );<br>
> ...<br>
> eventStream.insert(goodbye_message);<br>
> Thread.sleep(10000);<br>
> eventStream.insert(hello_message);<br>
> ksession.fireAllRules();<br>
> ksession.dispose();<br>
> logger.close();<br>
> } catch (Throwable t) {<br>
> t.printStackTrace();<br>
> }<br>
> } // end main() <-- tracing through the code, I get past the end of<br>
> main() then see a "Source not found." in the Eclipse debugger which seems<br>
> to be looking for "Thread.exit() line: 604"<br>
><br>
><br>
> The updated rule:<br>
><br>
> declare Message<br>
> @role( event )<br>
> end<br>
><br>
> rule "Hello World"<br>
> when<br>
> Message( status == Message.HELLO ) from entry-point "EventStream"<br>
> exists(Message( status == Message.GOODBYE ) over window:time( 4s ) from<br>
> entry-point "EventStream")<br>
> then<br>
><br>
> System.out.println("**************************************************");<br>
> System.out.println( "There was a GOODBYE message near the HELLO<br>
> message." );<br>
><br>
> System.out.println("**************************************************");<br>
> end<br>
><br>
> Thanks.<br>
><br>
><br>
> Edson Tirelli-3 wrote:<br>
>><br>
>> Although your rule should work, the best way to write your rule would<br>
>> be<br>
>> using temporal constraints instead of sliding windows:<br>
>><br>
>> rule "Goodbye before Hello World"<br>
>> when<br>
>> $m : Message( status == Message.HELLO )<br>
>> exists( Message( status == Message.GOODBYE, this<br>
>> before[0s,3s] $m ) )<br>
>> then<br>
>> System.out.println( "There was a GOODBYE message before<br>
>> the<br>
>> HELLO<br>
>> message." );<br>
>> end<br>
>><br>
>> Using "before" operator is not only much cheaper (in terms of used<br>
>> resources) than sliding windows, but it also allow the engine to reason<br>
>> over<br>
>> the temporal constraints looking for special cases, like when you use<br>
>> negative patterns.<br>
>><br>
>> I will look further into your case to check if I missed anything on<br>
>> the<br>
>> sliding windows support, but using STREAM mode should work.<br>
>><br>
>> If you can open a JIRA for me to raise a compilation error when<br>
>> compiling sliding windows using CLOUD mode, I appreciate. This will allow<br>
>> you to follow up my progress.<br>
>><br>
>> []s<br>
>> Edson<br>
>><br>
>><br>
>> 2009/3/30 ober0n <<a href="mailto:lili339@hotmail.com" target="_blank">lili339@hotmail.com</a>><br>
>><br>
>>><br>
>>> Hi Ed, no need to apologize, you have been invaluable in my first steps<br>
>>> towards Drooling :-D so thanks for all your help, it is GREATLY<br>
>>> appreciated<br>
>>> :clap:.<br>
>>><br>
>>> We have a few scenarios in mind but aren't really implementing them yet,<br>
>>> just trying to see if sliding windows works the way we think it does. In<br>
>>> the<br>
>>> simple rule I wrote above, I basically want to check if two facts are<br>
>>> temporally close.<br>
>>><br>
>>> Yes, you are correct. I didn't pay enough attention to the manual and<br>
>>> didn't<br>
>>> use STREAM mode to enter in my facts. I will use the manual insertion<br>
>>> process found in "Example 2.10. Inserting facts into an entry point" of<br>
>>> section "2.3. Streams Support" to update my code. And, I will update my<br>
>>> rule<br>
>>> to specify a "from entry-point <Specific Stream>".<br>
>>><br>
>>> Also, could you comment on the simple rule I am using? Does it look like<br>
>>> it<br>
>>> should work after I do the updates? Or is my logic incorrect?<br>
>>><br>
>>> Thanks again.<br>
>>><br>
>>><br>
>>><br>
>>> Ober0n,<br>
>>><br>
>>> Sorry for the delay on answering. I am on a trip with limited internet<br>
>>> connection.<br>
>>> I am interested in your experience with the sliding windows, since the<br>
>>> tests are working. Maybe it is a scenario not covered by the tests.<br>
>>><br>
>>> In any case, what is probably happening is that you are not<br>
>>> configuring<br>
>>> the engine to work in STREAM mode. The default mode is CLOUD and it does<br>
>>> not<br>
>>> support sliding windows. It seems the engine is silently failing in this<br>
>>> case, when the compiler raise an error to warn the user.<br>
>>><br>
>>> I just committed some docs on this subject:<br>
>>><br>
>>><br>
>>> <a href="https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-fusion/html/ch02.html#d0e1067" target="_blank">https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-fusion/html/ch02.html#d0e1067</a><br>
>>><br>
>>> (plz, wait for hudson to rebuild the docs or build docs yourself).<br>
>>><br>
>>> Feedback welcome. I will complement the sliding window docs.<br>
>>><br>
>>> []s<br>
>>> Edson<br>
>>><br>
>>> 2009/3/29 ober0n <<a href="mailto:lili339@hotmail.com" target="_blank">lili339@hotmail.com</a>><br>
>>><br>
>>> ><br>
>>> > Still trying to get sliding windows to work (basing my code off of the<br>
>>> > Eclipse supplied "Hello World" example). I don't think I fully<br>
>>> understand<br>
>>> > how it works yet so I'm trying to simplify things even further by<br>
>>> writing<br>
>>> > a<br>
>>> > simple rule that is meant to say:<br>
>>> ><br>
>>> > if (current_message = "Hello" AND exists( goodbye_message within<br>
>>> > sliding_window(3 seconds) ))<br>
>>> > then print("There was a GOODBYE message before the HELLO message." )<br>
>>> ><br>
>>> > In other words: This rule should fire if the current Hello World<br>
>>> message<br>
>>> > was<br>
>>> > preceeded within 3 seconds by a goodbye message.<br>
>>> ><br>
>>> ><br>
>>> ><br>
>>> ---------------------------------------------------------------------------------------------------<br>
>>> > I wrote a new rule for this:<br>
>>> ><br>
>>> > declare Message<br>
>>> > @role( event )<br>
>>> > end<br>
>>> ><br>
>>> > rule "Goodbye before Hello World"<br>
>>> > when<br>
>>> > Message( status == Message.HELLO )<br>
>>> > exists( Message( status == Message.GOODBYE ) over<br>
>>> > window:time( 3s ) )<br>
>>> > then<br>
>>> > System.out.println( "There was a GOODBYE message before<br>
>>> the<br>
>>> > HELLO<br>
>>> > message." );<br>
>>> > end<br>
>>> ><br>
>>> ><br>
>>> ><br>
>>> ---------------------------------------------------------------------------------------------------<br>
>>> ><br>
>>> > To send the messages: (ksession is a StatefulKnowledgeSession)<br>
>>> ><br>
>>> > ...<br>
>>> > ksession.insert(goodbye_message);<br>
>>> > ksession.fireAllRules();<br>
>>> ><br>
>>> > Thread.sleep(5000);<br>
>>> ><br>
>>> > ksession.insert(hello_message);<br>
>>> > ksession.fireAllRules();<br>
>>> > ...<br>
>>> ><br>
>>> ><br>
>>> ---------------------------------------------------------------------------------------------------<br>
>>> ><br>
>>> > I expect to get nothing back since I sent the Hello message 5 seconds<br>
>>> > after<br>
>>> > the goodbye message (outside the sliding window of 3 seconds). But,<br>
>>> for<br>
>>> > some<br>
>>> > reason the rule fires and I get one:<br>
>>> ><br>
>>> > "There was a GOODBYE message before the HELLO message."<br>
>>> ><br>
>>> > Any help would be greatly appreciated.<br>
>>> ><br>
>>> > Thanks!<br>
>>> > --<br>
>>> > View this message in context:<br>
>>> ><br>
>>> <a href="http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22770318.html" target="_blank">http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22770318.html</a><br>
>>> > Sent from the drools - user mailing list archive at Nabble.com.<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><br>
>>> ><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Edson Tirelli<br>
>>> JBoss Drools Core Development<br>
>>> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><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><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> View this message in context:<br>
>>> <a href="http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22785711.html" target="_blank">http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22785711.html</a><br>
>>> Sent from the drools - user mailing list archive at Nabble.com.<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><br>
>>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Edson Tirelli<br>
>> JBoss Drools Core Development<br>
>> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><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><br>
>><br>
>><br>
><br>
><br>
<br>
--<br>
</div></div>View this message in context: <a href="http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22844999.html" target="_blank">http://www.nabble.com/Trying-to-get-Sliding-Windows-to-work-tp22735051p22844999.html</a><br>
<div><div></div><div>Sent from the drools - user mailing list archive at Nabble.com.<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><br>
</div></div></blockquote></div></div></div><br><br clear="all"><br>-- <br><div><div></div><div> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</div></div><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><br>
<br></blockquote></div></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="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> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>