Business rule for accumulate function with Number fact using Guvnor
by mahesh_kharat
Hi,
I have written one business rule like following in my drl:
package ruleTest
import com.test.model.ErrorInfo
declare ErrorInfo
@role(event)
@timestamp(errorTimeStamp)
end
rule "Disk Capacity Threshold Error Rule"
when
Number( $totalDiskErrors:intValue,intValue == 5)
from accumulate($errorCount: ErrorInfo(errorCode=="00000011")
over window:time(60s)
from entry-point diskErrorEntryPoint,count($errorCount))
then
System.out.println("Disk Capacity Threshold Error Rule - Has
passed");
end
ErrorInfo is my fact which I have defined it to be of type event. In my
application, if many event comes having errorCode field's value as
"00000011" & count of those events has reached 5 over a window size of 60s
then print statement action should be carried out.This piece of rule is
working properly.
Now, I want to achieve same thing using Guvnor wherein I can define my
business rule. I tried creating fact Number & business rule for it but some
how it is not working. I am not getting any errors also. I have attached
images of my business rule & source of it.
So I have following doubts
1. How would I create new fact Number? Is it available in guvnor by default?
2. How to bind the result of accumulate with this fact Number?
If anyone knows about this, please do reply.
Thanks.
-Mahesh <http://drools.46999.n3.nabble.com/file/n4022861/DiskErrorRule.jpg>
<http://drools.46999.n3.nabble.com/file/n4022861/DiskErrorRuleSource.jpg>
--
View this message in context: http://drools.46999.n3.nabble.com/Business-rule-for-accumulate-function-w...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Re: [rules-users] Importing existing drl into Guvnor
by droolist
I noticed that as well... when you export and import the repository using
Guvnor the versions are lost. That may not be a big deal if you are
versioning your rules in some source control system.
If your Guvnor repository is a DB, you can do a DB import/export with the
tools your DB provides. You will have to play with it a bit to make it work.
One way I think for your multiple DRLs... connect to Guvnor using WebDav and
then copy them into Guvnor
--
View this message in context: http://drools.46999.n3.nabble.com/Importing-existing-drl-into-Guvnor-tp40...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Expert Systems and Functional programming?
by Matteo Mortari
Ciao everybody, I have a question I would like to submit to this community,
given Drools is my preferred choice for Expert Systems :)
A quick background: I'm not an Expert Systems / Rule engines expert, but
I'm a happy power user "of Rules" since my CS Engineering thesis, a paper
published, and used it with happy results at work and hobby projects.
Currently boarded on a new project with Rules+Processes at work, and still
very happy, so happy, I'm using Drools again in a new hobby project.
[semi-brag-mode off]
Now, in recent times, I cannot ignore what (apparently) is a strong
renaissance of Functional Programming, specifically all this momentum which
Scala and Java 8's Lambda's are getting.
The Question I'm asking myself: is there a specific, or few, areas where
Functional Programming could actually benefit Expert Systems so much to
actually spawn new paradigms of writing Rules? Or benefit in a new
generation of the Rete algorithm?
Or actually, Functional Programming will spawn a completely different
paradigm of system which will go beyond Expert Systems the way are designed
today?
Ignore my rant if you feel it's too generic, but I really wanted to seize a
chance to ask the question to this community :)
Thank you for your feedback,
Ciao,
Matteo
13 years, 3 months
Webservice application execution error ( CompositeKnowledgeBuilder)
by Kudos S
Dear All,
I created an axis2 project in WSO2 Carbon studio. This application basically running a Drools CEP application.I added drools 5.5.0 in the build path. In the eclipse console the program is running as standalone . But when I deploy this it into the WSO2 AS and execute the service I am getting the error in eclipse console rather than displaying the results.Please help me this is so important from me to resolve. I deployed the drools jar file inside wso2 application server (\wso2as-4.1.2\repository\lib) then also it showing the error.
Here is my error when I execute the service.
ERROR {org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver} - org/drools/builder/CompositeKnowledgeBuilder
java.lang.NoClassDefFoundError: org/drools/builder/CompositeKnowledgeBuilder
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilder(KnowledgeBuilderFactoryServiceImpl.java:38)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(KnowledgeBuilderFactory.java:56)
at Stream.MyTestCep.main(MyTestCep.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:66)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:199)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.wso2.carbon.bridge.BridgeServlet.service(BridgeServlet.java:164)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.wso2.carbon.server.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:154)
at org.wso2.carbon.server.TomcatServer$1.invoke(TomcatServer.java:254)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11NioProcessor.process(Http11NioProcessor.java:396)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:356)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1534)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.drools.builder.CompositeKnowledgeBuilder
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:443)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 40 more
[2013-03-15 10:03:42,384] ERROR {org.apache.axis2.receivers.AbstractMessageReceiver} - org.apache.axis2.AxisFault: org/drools/builder/CompositeKnowledgeBuilder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is my POM.XML
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>Stream.MyTestCep</groupId>
<artifactId>MyTestCep</artifactId>
<version>1.0.0</version>
<packaging>service/axis2</packaging>
<name>MyTestCep</name>
<description>MyTestCep</description>
<build>
<plugins>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>maven-axis2-plugin</artifactId>
<version>2.0.3</version>
<extensions>true</extensions>
<executions>
<execution>
<id>aar</id>
<phase>package</phase>
<goals>
<goal>aar</goal>
</goals>
</execution>
</executions>
<configuration />
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<buildcommands>
<buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
</buildcommands>
<projectnatures>
<projectnature>org.wso2.developerstudio.eclipse.axis2.project.nature</projectnature>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
</projectnatures>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<releases>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.5.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.5.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>5.5.0.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.2</version>
</dependency>
</dependencies>
</project>
13 years, 3 months
Unexpected Accumulate Collect behavior
by rymy8564
I'm using Spring AMQP to read messages from RabbitMQ. After a message is
read it's deserialized into one header (parent) object and multiple detail
(child) objects. Those facts are then inserted into a stateless rule
session. Finally, the updated facts are inserted into a database.
I have several rules that will aggregate the detail facts using either the
collect or accumulate functions. Here's an example.
rule "Header.TotalDuration"
when
h : BresHeader()
n : Number()
from accumulate( d : BresDetail(willSendToInvoice==true, uniqueConfID ==
h.uniqueConfID), sum(d.Duration) )
then
h.TotalDuration = new Integer(n.longValue());
System.out.println("[TotalDuration] rule ran");
end
If I run this once (reading in one message) in jUnit, the TotalDuration is
calculated correctly. If I run it in tomcat (continuously reading messages)
the values for TotalDuration are not correct and increase after each each
pass (message is grabbed, rules ran, facts persisted, repeat) and I can't
figure out why.
Can anyone shed light on this behavior?
--
View this message in context: http://drools.46999.n3.nabble.com/Unexpected-Accumulate-Collect-behavior-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
configuring timings for event expiry
by rule_dev
Hi ,
I was wondering if it is possible to write a rule in such a way that you are
able to set the 'this after' for events using an attribute from a class.
rule "correlate orders"
when
$bo : BuyOrderEvent( $id : id )
$ae : AckEvent( id == $id, this after[0,10s] $bo )
then
// do something
end
in the above rule template I would like to set the "this after [0,10]" part
using a custom value from say a date attribute of the BuyOrderEvent class.
Thanks for your time.
--
View this message in context: http://drools.46999.n3.nabble.com/configuring-timings-for-event-expiry-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months