Drools Fusion Dropping Actions to Events?
by chandu_divi
I am using Drools Fusion 6.0.1.Final version, it looks like some (rather
several) actions to the events are dropped. I am sending about 100K events
and expecting an action to all the events, but only 5000 actions are
performed, which means about 95K actopms are dropped.
The same issue was posted in the thread
http://drools.46999.n3.nabble.com/rules-users-Drools-Fusion-Dropping-Even...,
but it is marked as resolved.
The defect https://issues.jboss.org/browse/DROOLS-131 is also marked as
fixed.
But this issue seems to be appearing again.
Here is my code.
kmodule.xml
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="eventDrop" packages="ed" eventProcessingMode="stream">
<ksession name="edSession"/>
</kbase>
</kmodule>
ed.drl
package drools
import foo.TemperatureEvent
declare TemperatureEvent
@role(event)
end
rule "RULE S1"
when
$te:TemperatureEvent(measure <= 50) from entry-point entryone
then
System.err.println("The temperature at location - "+$te.getLocation() +
" is " + $te.getMeasure());
end
rule "RULE S2"
when
$te:TemperatureEvent(measure > 50) from entry-point entryone
then
System.err.println("The temperature at location - "+$te.getLocation() +
" is " + $te.getMeasure());
end
TemperatureEvent.java
package foo;
public class TemperatureEvent {
int measure;
String location;
long timeStamp;
public TemperatureEvent(int measure, String location, long timeStamp) {
this.measure = measure;
this.location = location;
this.timeStamp = timeStamp;
}
public int getMeasure() {
return measure;
}
public void setMeasure(int measure) {
this.measure = measure;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public long getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(long timeStamp) {
this.timeStamp = timeStamp;
}
}
App.java
package foo;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Random;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.EntryPoint;
public class App {
public static void main(String[] args) throws Exception {
System.setErr(new PrintStream(new FileOutputStream("report.txt")));
// Start Drools.
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
final KieSession kSession = kContainer.newKieSession("edSession");
EntryPoint entryPoint1 = kSession.getEntryPoint("entryone");
new Thread() {
@Override
public void run() {
kSession.fireUntilHalt();
}
}.start();
Random measure = new Random(System.currentTimeMillis());
Random location = new Random(System.currentTimeMillis() - 1000000L);
String locations[] = { "Bangalore", "Chennai", "Delhi", "Mumbai",
"Kolkata" };
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < 1000; ++j) {
TemperatureEvent te = new TemperatureEvent(
measure.nextInt(100),
locations[location.nextInt(5)],
System.currentTimeMillis());
entryPoint1.insert(te);
// Thread.sleep(1);
}
}
Thread.sleep(100);
kSession.halt();
kSession.dispose();
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Fusion-Dropping-Actions-to-Event...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
Distributed Drools
by Daniel Souza
Hi all, I'm looking for some distributed solution available with drools. I
want to create a distributed Multi-agent architecture for my project using a
shared working memory.
Searching for solutions, I found the DJess and Octopus solution that use the
Jess inference engine.
For Drools, I found this one:
http://www.plugtree.com/making-a-non-persistent-ha-knowledge-session/
It seems that Kie is flexible enough to distribute the knowledge session in
local ksessions, but I think that the ha-ksession doesn't provide a shared
working memory to different kbases. Seeing the sample project, there's just
one rule set (drl) with only one rule. I can use as a sample model to do
what I want to do. This project showed me how I can extend the Kie and
implement my own.
I'm not familiar with Drools 6 yet, but I'm reading papers about distributed
Rule-Based Systems concerning Multi-Agent Systems solutions and I didn't
find any solution using Drools. The majority solutions were provided using a
shared working memory with local copies.
*Than, it gives me a question: is it possible to create a shared working
memory with Drools?*
To refresh What I mean, there's an old paper showing differences between
Blackboard Systems and Rule-Based Systems (see Figure 1).
<http://drools.46999.n3.nabble.com/file/n4029338/production_systems_vs_bla...>
In Figure 1, the Blackboard is a shared working memory to insert facts,
where each knowledge source (KS) is activated according with the facts
inserted. Each KS is a specific expert with your own rules set that look for
the blackboard to produce partial solutions that can be seen as new facts to
be inserted in the blackboard. These partial solutions can activate more KS
to produce new partial solutions until the final solution be reached. In
contrast, in production systems, we build a knowledge base with a set o
rules that can be activated according with facts inserted in a local working
memory (there's no shared working memory between others kbases with their
own rules set).
In DJess, the authors introduce a model for distributing rule-based
inference systems called Web of Inference Systems (WoIS). Each member of
WoIS is composed of an inference system (IS) and a rule base, while all ISs
operate on a single Shared Working Memory (SWM). WoIS is controlled by a
dedicated
component called manager (M). Each IS holds a copy of a part of the SWM in
its local working memory, while all ISs run independently in parallel. This
model was utilized to implement a distributed version of Jess called DJess.
Synchronization between interfering rules is achieved by means of shadow
facts and ghost facts. A shadow fact is a Jess fact linked to a Java bean
object. Each shared fact is implemented as a shadow fact, and thus an
associated Java bean object is created. All the proxies corresponding to the
same shared fact are linked together by means of a Java remote object called
ghost fact. Access of the ISs to the ghost facts are synchronized by
acquiring locks during the transition from the conflict resolution stage to
the act stage of an inference cycle.
If not were done yet, I want to implement my own approach using Drools. I
don't know if I can reach the final solution using Drools, but it seems the
the Kie is flexible enough to be extend and I implement something. I'm
planning to use the FIPA Subscribe protocol to synchronize the Shared
Working Memory with a local working memory for each agent.
"The FIPA Subscribe Interaction Protocol (IP) allows an agent to request a
receiving agent to perform an action on subscription and subsequently when
the referenced object changes"
<http://fipa.org/specs/fipa00035/SC00035H.html>
Regards,
Daniel Souza
--
View this message in context: http://drools.46999.n3.nabble.com/Distributed-Drools-tp4029338.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
Re: [rules-users] (Hot?) rules production deployment
by Pykhtin, Alex
Thank you, Steve,
I looked at KnowledgeAgent and KieScanner documentation and looks like this is something that can help in hot deployment, but not so much in safe proofing.
Here are some basic facts (or misconceptions) that I have gathered so far:
1. KnowledgeAgent and KieScanner are able to dynamically detect changes in the rules (and other resources) and hot-deploy them to running Drools installation;
2. KnowledgeAgent belongs to Drools 5.X. In 6.X it is deprecated in favor of KieScanner (which is available starting 6.0.X);
3. KnowledgeAgent transmits changes through monitoring file system for .DRL files or via HTTP connection to a running Guvnor instance;
4. KieScanner transmits changes through monitoring Maven repository. It appears like old KnowledgeAgent's ability to transmit individual .DRL files is deprecated;
5. Neither KnowledgeAgent nor KieScanner have a built-in mechanism for error handling, at least not a sophisticated one. There is no way to perform a rollback if at some point it becomes clear that a new update is a bad one.
Thanks,
Alex
> If you want to hot-deploy rule changes, just take a look at the documentation on knowledge agents or KieScanner (v6). It's also easy enough to code a knowledge base reload yourself.
>
> However, you say:
>
> Ideally we would like business users to add or modify rules in Production without risk of crashing entire rules engine.
>
> Rules and facts are code, so changes could crash your system if written poorly. Supporting hot deployment does not mean that you don't need to regression test your changes. All it means is that you can break your system much more quickly than before.
>
> The only way to get around this is to write your own UI, which prevents users from making any rules or fact changes that 'break' your system. How you achieve that is very much dependent on what you want users to change and how much time you are prepared to spend writing automated tests to prevent breaking changes from being deployed.
>
> Steve
11 years, 8 months
Is there a better way to write this rule?
by Leonard93
When I have the following rule:
rule "Discount Egypt"
salience 0
when
$T : TripRequest ( destination == "Egypt" )
then
((DiscountResult) $T.getResult()).setDiscount(5);
end
Is there a better way to do the 'then' part of the rule (when it comes to
formatting, but still executes the same thing)?
My request object has a result object that has a method called setDiscount
that needs to be called.
The setDiscount cannot be in the request object because there are multiple
kinds of Result Objects, thus the casting to its type.
This rule works fine, I was just wondering if there are any easier ways to
do it. I already found out you can do 'destination' instead of
'getDestination()' which helps make the rules more readable.
--
View this message in context: http://drools.46999.n3.nabble.com/Is-there-a-better-way-to-write-this-rul...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
(Hot?) rules production deployment
by Pykhtin, Alex
Thank you, Steve,
I looked at KnowledgeAgent and KieScanner documentation and looks like this is something that can help in hot deployment, but not so much in safe proofing.
Here are some basic facts (or misconceptions) that I have gathered so far:
1. KnowledgeAgent and KieScanner are able to dynamically detect changes in the rules (and other resources) and hot-deploy them to running Drools installation;
2. KnowledgeAgent belongs to Drools 5.X. In 6.X it is deprecated in favor of KieScanner (which is available starting 6.0.X);
3. KnowledgeAgent transmits changes through monitoring file system for .DRL files or via HTTP connection to a running Guvnor instance;
4. KieScanner transmits changes through monitoring Maven repository. It appears like old KnowledgeAgent's ability to transmit individual .DRL files is deprecated;
5. Neither KnowledgeAgent nor KieScanner have a built-in mechanism for error handling, at least not a sophisticated one. There is no way to perform a rollback if at some point it becomes clear that a new update is a bad one.
Thanks,
Alex
> If you want to hot-deploy rule changes, just take a look at the documentation on knowledge agents or KieScanner (v6). It's also easy enough to code a knowledge base reload yourself.
>
> However, you say:
>
> Ideally we would like business users to add or modify rules in Production without risk of crashing entire rules engine.
>
> Rules and facts are code, so changes could crash your system if written poorly. Supporting hot deployment does not mean that you don't need to regression test your changes. All it means is that you can break your system much more quickly than before.
>
> The only way to get around this is to write your own UI, which prevents users from making any rules or fact changes that 'break' your system. How you achieve that is very much dependent on what you want users to change and how much time you are prepared to spend writing automated tests to prevent breaking changes from being deployed.
>
> Steve
11 years, 8 months
java.lang.NoSuchMethodError thrown in drools api
by DE_Azrael
Hi everyone,
I'm using drools 5.5.0 final in my project.
The project is already running since a couple of years by now and I'm new in
the project. I did some tuning on the JBOSS and the source code and deployed
a new version.
Since than I have a strange behaviour on one interface. The first 4 to 6
transactions are working fine. Than I'm receiving a "NoSuchMethodError" from
my insertFact method.
Caused by: java.lang.NoSuchMethodError:
java.lang.StringBuilder.append(Ljava/util/Date;)Ljava/lang/StringBuilder;
at
ConditionEvaluatorf4a3f354729241ac8370890200fdf2d8.evaluate(Unknown Source)
at
org.drools.rule.constraint.MvelConstraint.evaluate(MvelConstraint.java:200)
at
org.drools.rule.constraint.MvelConstraint.isAllowedCachedRight(MvelConstraint.java:184)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:134)
at org.drools.reteoo.NotNode.assertObject(NotNode.java:131)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:350)
at
org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:311)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:903)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
at
de.hp.ipcc.speechLogic.tools.DroolsHelper.insertFact(DroolsHelper.java:208)
at
de.hp.ipcc.speechLogic.fixedNet.SpeechLogicFnBean.getOrders(SpeechLogicFnBean.java:443)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
at
org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72)
at
org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:138)
... 99 more
So I did a fallback on the old version (without my tuning changes) and the
funny thing is that the failure is now also happening there .... but it has
never been registered before.
I checked the information that I'm inserting into drools for the cases where
everything is working fine and where the failure occurs. The information are
identical.
Here the code where the failure is thrown:
//orders are in dto, now load delta information for customer,
//so drools can relate them to the order
if(customerNumber != null && customerNumber.trim().length() > 0){
SpeloDeltaDao deltaDao = new SpeloDeltaDao();
Collection<Spelo_Delta> deltaList =
deltaDao.getDeltaInfos(DELTA_CATEGORY_ORDERS, customerNumber);
if(deltaList != null){
for(Spelo_Delta sd : deltaList){
dh.insertFact(sd);
}
if(logga.isDebugEnabled()){
msg = new StringBuilder().append("Inserted ").append(deltaList.size());
msg.append(" spelo_delta records for customer
<").append(customerNumber).append(">");
if(logga.isDebugEnabled()) {
logga.debug(msg);
}
}
}
public FactHandle insertFact(Object proposition){
FactHandle fh = null;
if(ksession != null){
fh = ksession.insert(proposition);
}
return fh;
}
Not sure if it is important how the KnowledgeBAse and session is defined
.....
public class DroolsHelper implements Constants {
protected static KnowledgeBase kbase = null;
StatefulKnowledgeSession ksession = null;
.........
So by now I have no clue what could be wrong and it would be really cool if
one of you could help me.
Thanks
Johannes
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-NoSuchMethodError-thrown-in-d...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 8 months
Re: [rules-users] (Hot?) rules production deployment
by Pykhtin, Alex
Anyone can tell if Drools supports hot deployment of rules and fact types?
We are using Drools rules (No Guvnor/Workbench), and the whole cycle Development-Test-Production takes a very long time. Ideally we would like business users to add or modify rules in Production without risk of crashing entire rules engine. But as of today, any rule or fact type change is subject to full regression testing, as any other of our Java code. I tried to experiment with Drools Workbench, but so far it doesn't look like it can help much with hot deployment. Workbench can greatly streamline the development and deployment process, but generally speaking, since all Drools boils down to Java, it is essentially another jar deployment. So, it looks like if we would want to simplify our production deployments, the only option is to abolish the QA cycle for Drools jars (which our QA will probably never agree to).
Any ideas?
Thanks,
Alex
11 years, 8 months