How to use global variables
by goforcrazy
Hi All,
My rule file is as shown below:
global Integer count;
rule "Rule1"
when eval(1==1)
then
for(int a = 0; a<10; a++)
{
System.out.println("1 COUNT: " + count);
count++;
}
rule "Rule 2"
when eval(1==1)
then
for(int a = 0; a<10; a++)
{
System.out.println("2 COUNT: " + count);
count++;
}
As shown above I have created a global variable count in my drools file. In
my Java file I have included ksession.setGlobal("count", 1); to start the
count from 1 for first rule but after Rule 1 gets executed and before the
beginning of rule 2 I find that count value is again taken as 1. It does not
remember the last count value at the end of the loop.
I understand I need to use the workingMemory function to update the result
of count but I am not sure on how and where to update the same.
Any help regarding this will be greatly appreciated.
Thanks and Regards,
Malathi
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-use-global-variables-tp4022860.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
Issue in writing business rule with Drools Guvnor 5.5.0 and Jboss as 7.0.2
by mahesh_kharat
I am using drools guvnor 5.5.0 with jboss as 7.0.2.
I want to write one business rule but I am getting following issues :
1. When I am selecting "From entry-point" from list of facts, guvnor
doesn’t give facility to add "Any of the following are true" condition in
add pattern of "From entry-point".
2. When I am selecting "Any of the following are true" from list of
facts, guvnor doesn’t give facility to add "From entry-point" condition in
add pattern of "Any of the following true".
Has anyone faced the same situation? Please provide your throughts on
this issue, how to overcome the issue?
- Mahesh
--
View this message in context: http://drools.46999.n3.nabble.com/Issue-in-writing-business-rule-with-Dro...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 9 months
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.
11 years, 9 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.
11 years, 9 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
11 years, 9 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>
11 years, 9 months