How to invoke rules in KieSession utilizing the CEP feature within Camel?
Issue
- The requirement is that while running the
CEP (Complex Event Processing)
withinCamel route
, rules need to be invoked every time whenKieSession
is being used to insert events/facts (e.g. events of typecom.mycompany.camel.spring.StatefulBeanFact
which is inserted inKieSession
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 isstateless
. WhileKieSession
is used the rules are fired just once. How to invoke rules instateful ksession
orKieSession
utilizing theCEP
feature withinCamel
?
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.