How to invoke rules in KieSession utilizing the CEP feature within Camel?

Solution Verified - Updated -

Issue

  • The requirement is that while running the CEP (Complex Event Processing) within Camel route, rules need to be invoked every time when KieSession is being used to insert events/facts (e.g. events of type com.mycompany.camel.spring.StatefulBeanFact which is inserted in KieSession every time the route is executed). Referring to brms-fuse-osgi-examples to set up a development environment for integration, it appears that rules are invoked only when the session is stateless. While KieSession is used the rules are fired just once. How to invoke rules in stateful ksession or KieSession utilizing the CEP feature within Camel?

camel-context.xml

...
    <route id="StatefulRules">
        <from uri="timer:foo?period=30s"/>
        <log message="Logging message to Stateful  Rules"/>
        <to uri="kie:ksession-stateful?action=insertBody"/>
    </route>
...

kie.xml

...
<bean id="statefulFact" class="com.mycompany.camel.spring.StatefulBeanFact" >
        <property name="firstName" value="Musharraf"/>
        <property name="secondName" value="Hussain"/>
        <property name="stateful" value="true" />        
    </bean>
...
    <bean id="kiePostProcessor" class="org.drools.osgi.spring.OsgiKModuleBeanFactoryPostProcessor" />
    <kie:kmodule id="camel-context">
        <kie:kbase name="drl">
            <kie:ksession name="ksession-stateful" type="stateful">
            </kie:ksession>
        </kie:kbase>
    </kie:kmodule>
...

SampleRule.drl

    package com.redhat.sample..drools;

    rule "TestRule"
    when
        eval( true )
    then
        System.out.println("Simple Rules are getting invoked");
    end

Environment

  • Red Hat JBoss Fuse (Fuse)
    • 6.2.0
  • Red Hat JBoss BRMS (BRMS)
    • 6.1.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content