[jboss-jira] [JBoss JIRA] Closed: (JBRULES-2150) stream mode requires DroolsStreamUtils

Edson Tirelli (JIRA) jira-events at lists.jboss.org
Mon Jul 12 13:00:47 EDT 2010


     [ https://jira.jboss.org/browse/JBRULES-2150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Edson Tirelli closed JBRULES-2150.
----------------------------------



> stream mode requires DroolsStreamUtils
> --------------------------------------
>
>                 Key: JBRULES-2150
>                 URL: https://jira.jboss.org/browse/JBRULES-2150
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core (fusion)
>    Affects Versions: 5.0.1.FINAL
>            Reporter: Jaroslaw Kijanowski
>            Assignee: Edson Tirelli
>             Fix For: 5.1.0.CR1
>
>         Attachments: cep.drl, CEPTest.java, Sensor.java
>
>
> I'm using sliding windows (hence stream mode).
> Here's my rule:
> rule 'r'
> when
> Number( dv:doubleValue > 1 ) from accumulate(
>         Sensor( $v : value ) over window:length( 2 ),
>         average( $v ) )
> then
>     System.out.println(dv);
> end
> Here's my class:
> ++++++++++++++++++++++++++++++++++++++++++++++
> public class CEPTest {
>   public static void main(String[] args) throws Exception {
> .
> .
> .
>     kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
>     KnowledgeBase kbase2 = (KnowledgeBase) DroolsStreamUtils.streamIn(DroolsStreamUtils.streamOut(kbase), null);
>     final StatefulKnowledgeSession ksession = kbase2.newStatefulKnowledgeSession();
>     System.out.println("T1");
>     ksession.insert(new Sensor(1.0));
>     ksession.fireAllRules();
>     System.out.println("T2");
>     ksession.insert(new Sensor(2.0));
>     ksession.fireAllRules();
>     System.out.println("T3");
>     ksession.insert(new Sensor(3.0));
>     ksession.fireAllRules();
>     ksession.dispose();
>   }
> }
> ++++++++++++++++++++++++++++++++++++++++++++++
> The output is (as expected):
> +++++++++++++++
> T1
> T2
> 1.5
> T3
> 2.5
> +++++++++++++++
> I'm wondering why I have to use DroolsStreamUtils to get a knowledge base? When I use kbase (which didn't went through DroolsStreamUtils) instead of kbase2 to create a new session, the output will be:
> +++++++++++++++
> T1
> T2
> 2.0
> T3
> 3.0
> +++++++++++++++ 
> Attaching all 3 files needed to reproduce - rule, model and test.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list