Integrating Drools with rules from a legacy BRMS
by bdolbeare
I am working on integrating Drools with a legacy BRMS that was developed
in-house. The customers like the BRMS and are unwilling to migrate to
another tool such as Guvnor. The BRMS creates the rules in a proprietary
XML format. In order to integrate Drools with the BRMS, I need to convert
these rules to a format that Drools understands and that leaves me with what
seems like 3 options:
1) Write some XSLT to transform the proprietary XML to Drools XML format.
This seems straightforward; however, I am concerned that the online
documentation states that the Drools XML format should be considered
deprecated. I'd hate to invest much time in this approach if the XML support
is going to disappear in a future release.
2) Write my own parser that can convert the proprietary XML to classes in
the org.lang.descr package. I'm not sure if the Drools developers intend for
others to use these classes directly. For instance, if they change
frequently, this approach may be difficult to maintain.
3) Write my own parser that can convert the proprietary XML to DRL. This
approach seems unfortunate in that the rules would be parsed twice; first to
convert them to DRL and then internally by the Drools DrlParser. Also, this
doesn't seem to offer any benefit over approach 2 (except that I know DRL
well and wouldn't have to learn how the org.lang.descr classes work [not
much documentation in those classes]).
Right now, I'm leaning towards approach 2. Any thoughts or suggestions
would be appreciated.
--
View this message in context: http://drools.46999.n3.nabble.com/Integrating-Drools-with-rules-from-a-le...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Possibly race condition in a persisted Drools + JBPM during a StatefulKnowledgeSession
by Alberto R. Galdo
Hi all,
We've been for long time now developing a complex event processing
system that ( simplified version ahead !! ) involves a set of rules that in
turn activates a set processes that fulfill human tasks and other kind of
tasks.. This all is running in a StatefulKnowledgeSession with JPA
persistence configured both for Drools and JBPM. We are running an stack of
Drools, JBPM, Drools Integration, Drools fussion, etc..
We've been able to persist Drools sessions & JBPM processes in the same
Persistence Context ( not without pain :( ) using different JTA
implementations including ( but not limited to ) Bitronix & Atomikos.
What we are observing here is what seems to be some kind of race
condition between Drools and JBPM when running the knowledge session when
JPA&JTA persistence is configured. Very often, as soon as after 2-3
processes get created as rule's consequences are fired in response of
events inside the session we see how JBPM finds its instance nullified by
Drools when it tries to end a process and persist it.
We've been able to find where Drools decides to delete an instance of
the process ... at a given time Drools executes
JPAProcessInstanceManager.clearProcessInstances() [1] when it finalizes a
SingleSessionCommand wich in turn calls disconnect() for *all* the
local-stored processinstances ( wich gets populated with instances of
processes every time a process is started in the knowledge session ):
public void clearProcessInstances() {
for (ProcessInstance processInstance: new
ArrayList<ProcessInstance>(processInstances.values())) {
((ProcessInstanceImpl) processInstance).disconnect();
}
}
So, Drools decides to disconnect all process instances in it's JPA
context without taking in account the state the process is in, and when an
processinstance that is not stopped gets removed then JBPM finds it's
NullPointerException...
We've modified the code to make Drools aware of the state of the
process before wiping it from the context ( no problem here, there will
be no leak as a running processinstance will be removed in future calls of
"clearProcessInstances" given the process is closed ). But unfortunatelly
this seems to resolve this problem, but lots of other problems ( wich seems
also race conditions arise : for instance: Drools closes connections to
the database and JBPM finds the connection closed,
So, we are really worried about using Drools & JBPM in a persisted
environment. Maybe our asumptions are wrong... Is it possible to have an
scenario like ours given the current Drools & JBPM integration status for a
persistent statefulKnowledge Session? Did anyone build a complex event
processing system like ours in a unaltered persistence environment such as
provided in Drools and JBPM by default?
Greets,
[1]
https://github.com/droolsjbpm/jbpm/blob/master/jbpm-persistence-jpa/src/m...
Alberto R. Galdo
argaldo(a)gmail.co <argaldo(a)gmail.com>
14 years
Lots of org.drools.common.ScheduledAgendaItem instances in memory
by Werner Stoop
Hi,
We're using Drools with a StatefulKnowledgeSession to process events coming
from equipment in our network. The system draws conclusions about the state
of the equipment and writes those conclusions to a table in our
database. All our rules work as we expected and the system produces the
correct results.
However, the memory usage of the JVM steadily goes up when the system runs
for extended periods of time until we start getting OutOfMemoryExceptions
and the server has to be restarted. This is in spite of the fact that the
fact count reported by
the StatefulKnowledgeSession.getFactCount() stays reasonably stable,
with around 30 000 facts (give or take) at any point in time.
I have run the Eclipse Memory Analyzer tool (http://www.eclipse.org/mat/)
against heap dumps from the JVM several times now, and every time it
reports more and more instances
of org.drools.common.ScheduledAgendaItem referenced from one instance of
java.lang.Object[]
To be concrete, since this morning the uptime is more than 112 hours in
total, during which the system has processed little over 2 000 000 events
from the network. It has 29 000 facts in the knowledge session, yet in the
heap dump we see 829 632 instances of org.drools.common.ScheduledAgendaItem.
What is the ScheduledAgendaItem for? Is there something wrong with my rules
that causes this many instances to be held? Is there something I should do
to release these instances or the Object[] holding on to them?
Thanks,
Werner Stoop
14 years
how to use only updated value in drools
by learner
I am having a drl file with 2 rules
The 1st rule updates a attribute, say updates attribute b to 10 based on
some condition.
The 2nd rule has a check for values with b not equal to 10. It logs error
for those values not equals to 10.
The b value gets updated to 10 in rule 1. However in the second rule it does
not use updated value and logs error.
Is there a way to use the updated b value in the 2nd rule. I tried using
modify but still the error gets logged.
--
View this message in context: http://drools.46999.n3.nabble.com/how-to-use-only-updated-value-in-drools...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Re: [rules-users] NoClassDefFoundError: org/drools/lang/DRLLexer
by bharadwaj2012
kbuilder.add(
ResourceFactory.newClassPathResource("COBValidation.drl"),
ResourceType.DRL);
and have follwing dependenies
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow</artifactId>
<version>${jbpm-flow.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>${knowledge-api.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools-core.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools-compiler.version}</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
<version>${antlr-runtime.version}</version>
</dependency>
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
<version>${mvel2.version}</version>
</dependency>
--
View this message in context: http://drools.46999.n3.nabble.com/NoClassDefFoundError-org-drools-lang-DR...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years
Drools Fusion: expiration
by Matteo Cusmai
Hi all,
i have noticed a strange behavior, but i am not sure that i depend on
drools or depend by my bad knowledge of it.
I am using drools fusion and i have a lot of classes with role event. I
have put them the expiration value to 5 minutes.
>From my understanding, if i use explicit expiration, as i do, when it pass
5 minutes and that event is out of scope of all my rules, that event is
deleted.
But, i noticed that the last event hasn't retracted after 5 minutes and
this behavior makes the system no stable, because it works differently
after some minutes.
If i don't use explicit expiration, the system seems to work fine, so i am
however happy, but i would like to understand the issue.
Thanks a lot,
Matteo.
14 years
Time Sliding Window Question
by Bernhard Unger
Hello,
I am fairly new to Drools and tried my first steps with Drools Fusion and
was running into the following problem:
According to the Drools Fusion User Guide Version 5.4.0.Final on page 32 the
following pattern should work and select events in between the last 10
minutes:
...
StockTick() over window:time( 2m )
...
I tried the following example, simulating RHQ EventComposite Events with a
simple Junit test:
...
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(new ClassPathResource("rhqrules.drl", getClass()),
ResourceType.DRL);
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
nowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
KnowledgeSessionConfiguration conf =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
conf.setOption(ClockTypeOption.get("pseudo"));
ksession = kbase.newStatefulKnowledgeSession(conf, null);
...
inside the test method:
...
For-Loop inserts new Events and increases the pseudo clock in one minute
steps:
...
for (int i = 0; i < 100; i++) {
timestamp = clock.advanceTime(1, TimeUnit.MINUTES);
ksession.insert(new EventComposite("EventDetail" + i, resourceId,
"resourceName" + i, "resourceAncestry" + i, resourceTypeId,
eventId, severity, "sourceLocation" + i, timestamp));
}
...
ksession.fireAllRules();
...
The .drl definition should fire only events of the last 10 minutes, however
all inserted 100 events are fired:
declare EventComposite
@role( event )
end
rule "Rule1 events in between last 10 minutes"
when
$event : EventComposite() over window:time( 10m )
then
System.out.println("Event in between the last 10 minutes:: " + $event);
end
On the other hand this rule works as expected and selects only events older
than 10 minutes:
rule "Rule2 events not in between the last 10 minutes"
when
$eventA : EventComposite( )
not EventComposite( this.resourceId == $eventA.resourceId ) over
window:time( 10m )
then
System.out.println("Event not in between the last 10 minutes: " +
$eventA);
end
My question is:
What did I wrong in the definition of Rule-1, what is the correct statement
for finding the last 10 minutes events?
Background information:
I am doing some research on implementing using the drools framework inside
the RHQ framework for complex event processing. I would like to show that
this is possible and could be uses reasonable for RHQ event processing.
Any help is highly appreceated!
Thanks and kind regards
Bernhard
14 years