Problem with Drools 4.0.3
by prateek.katiyar@wipro.com
Hello all
I am using Drools4.0.3
I have a J2EE application that I am running on Tomcat.
I am using a singleton class in which I am doing the following steps in the constructor :
PackageBuilderConfiguration pkgBuilderCfg = new PackageBuilderConfiguration();
JavaDialectConfiguration javaConf = (JavaDialectConfiguration) pkgBuilderCfg.getDialectConfiguration( "java" );
javaConf.setCompiler( JavaDialectConfiguration.JANINO );
builder = new PackageBuilder(pkgBuilderCfg);
ruleBase = RuleBaseFactory.newRuleBase();
Also I am using a method in the same class to validate the inputs which is as follows:
private void validateXML() throws Exception
{
String drlStr = null;
InputStreamReader drl = null;
File ruleFile = new File(this.fileName);
long curLMTime = ruleFile.lastModified();
if(!(curLMTime == lmdTimeForXML))
{
lmdTimeForXML = curLMTime;
if(strReader != null) {
strReader.close();
strReader = null;
}
if(pkg != null){
String packageName = (ruleBase.getPackage("jbossrules")).getName();
if(packageName != null && packageName.equals("jbossrules")){
Rule[] rules = (ruleBase.getPackage("jbossrules")).getRules();
if(rules != null){
for (int i=0; i<rules.length; i++){
String ruleName = rules[i].getName();
try {
ruleBase.removeRule(packageName,ruleName);
}catch(NullPointerException ne){
}
}
}
}
}
try {
drl =new InputStreamReader(new FileInputStream(this.fileName));
drlStr = this.getInputStreamAsString(drl);
strReader = new StringReader(drlStr);
builder.addPackageFromXml(strReader);
pkg = builder.getPackage();
ruleBase.addPackage(pkg);
} catch (IOException e) {
e.printStackTrace();
log.error("*********Can not create inputstrea************", e);
lmdTimeForXML = 0;
throw e;
//removeRules();
}catch (Exception e) {
e.printStackTrace();
log.error("*********CAN NOT CREATE THE RULE BASE INSTANCE************", e);
lmdTimeForXML = 0;
throw e;
//removeRules();
}finally {
try {
if(drl != null) {
drl.close();
}
} catch (IOException e) {
e.printStackTrace();
log.error("*********Can not create inputstrea************", e);
}
}
}
StatefulSession session = ruleBase.newStatefulSession();
session.insert(this.beanObj);
session.setGlobal("response",this.response);
if(this.assertObjArr != null && this.assertObjArr.length > 0)
{
for(int i=0; i<this.assertObjArr.length; i++)
session.insert(this.assertObjArr[i]);
}
Agenda agenda=session.getAgenda();
AgendaGroup agendagroup=agenda.getAgendaGroup(this.getMethodName());
session.setFocus(agendagroup);
session.fireAllRules();
ResponseBean res = (ResponseBean)session.getGlobal("response");
this.setResponse(res);
session.clearAgenda();
session.setGlobal("response",null);
session.dispose();
session = null;
}
Now when I am deploying any wrong rule,it gets stored in the memory.If again I am deploying the rules then the previous wrong rules are not deleting.
Please suggest me how can I overcome this problem?
With Regards
Prateek
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
17 years, 1 month
How to make a "Loop-Ruleflow"????
by mmquelo massi
Hi everybody.
I am trying to make a ruleflow that, once processed, causes the rule engine
to infinitely loop.
I have got a *User* Object in my object model. It has got a *getLogin()* and
*setLogin(*) methods.
The login field stands for the "User name", so it is a String.
First I insert an Object in the WM, with login==A.
Then I generate the following rule-flow-groups:
*rule "rule_ab" *
* ruleflow-group "ab" *
* when *
* u:User( login == "A" ) *
* then *
* u.setLogin("B"); *
* System.out.println("a - > b"); *
* update(u); *
*end *
**
*rule "rule_ba" *
* ruleflow-group "ba" *
* when *
* u:User( login == "B" ) *
* then *
* u.setLogin("A"); *
* System.out.println("b - > a"); *
* update(u); *
*end *
I'd like to define a ruleflow that gives me in output something like this:
a - > b
b - > a
a - > b
b - > a a - > b
b - > a
a - > b
b - > a a - > b
b - > a
a - > b
b - > a
.... looping...
How can I do it?
In other words I want those rules to be executed in parallel and I want to
define
this "parallelism" using the ruleflow graph, Is It Possible???
Thank You Again!
Massi.
P.S.
Ah.... I solved that matter with the rule.package...
17 years, 1 month
Repository Export/Import
by Darko IVANCAN
JBoss DRools 4.0.3
JBoss AS 4.0.5
JDK 1.5.13
Hi,
In the process of designing our infrastructure we're looking at how
DRools could be used with staging environments.
The easy part:
We have per environment one BRMS-Server and in the same environment some
other servers running the Rules-Application, which will get the LATEST
rules from the BRMS-Server, using polling and a JMX/JMS trigger.
The tricky part:
We had the idea of taking a "valid version" from one stage to another.
So we could either use rule packages (snapshots) or repository exports.
As I see no easy way of passing a package from one BRMS to another, the
export/import options seems a feasible option.
My issue here is now, that this does not seem to work:
a) It takes an incredible amount of time to upload an export.
b) It seems, that the import has no effect to the contents shown in the
BRMS, after the import.
We do not want to go with the RuleAgent, as the environments should
really be separated.
So my question:
Is there an easy way to migrate data from one BRMS to another, so it can
be used by the RuleAgents ?
The RuleAgents will use an URI to pick up the LATEST version.
The Web-Interface itself of the BRMS is not needed, just the URI-Source
for the Rule-Agents.
Any ideas, hints ?
Thanks,
Darko Ivancan
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
17 years, 1 month
Indep stated Sub Conditions Vs AND
by Arjun Dhar
Whats the difference between:
when
<Sub Condition A>
<Sub Condition B>
Then
...
End
Vs
when
<Sub Condition A> and <Sub Condition B>
Then
...
End
..Assumping I have no need to use variables between A & B, do I get a
performance improvement using "AND" or does the Rete evaluate faster if the sub-
conditions are stated independently?
Thanks in advance
17 years, 1 month
Why no breakpoints in drl files ??
by Michael Zimmermann
Hi there,
well, in one project I do have the problem that from within eclipse while
debugging the application breakpoints in drl files are not recognized,
i.e. the application does not stop on aline if this line is executed.
Weirdly, a second project in the same eclipse installation does not show
this behaviour.
The problematic project
- is converted to a drools project
- is started via "debug as > drools"
- has the breakpoint set in a rule consequence (system.out) that gets
executed
Any ideas what might be the reason for such a behaviour?
thanks and cu, Michael
PS: I doubt that it is the fault of my eclipse installation because the
second drools test project works fine.
17 years, 1 month
How and when are objects released in Stateless Session
by Arjun Dhar
Hi,
can someone please explain; if a stateless session is used over a log period
of time. How are the objects (rather the shadows to them) released?
I understand that as long as a class is not final, its shadow is created and
used. This raises a concern about the life cycle of that object.
perhaps the cause of memory leaks in the past.
Wanted to nkow the life cycle in breif.
Thanks
17 years, 1 month
Design guidelines regarding session pools
by Mikael Larsson
Hi!
I have some questions about multithreaded apps and if it is necessary to
pool session objects for performance.
* I understand that it is expensive to create the RuleBase objects but
what about the sessions?
If I create a new stateful session object for each request will that
become a potential bottleneck?
* Is the session class thread safe, what will happen if two or more
threads simultaneously call fireAllRules on one and the same session
object?
One advantage of pooling session is if you have some data that does not
change per request. Say that I have some data associated with a specific
type of request that should be inserted for all requests of that
particular type and evaluated towards request specific stuff, e.g.
params in the request. E.g. An object that specifies allowed values for
a particular API will be the same for all requests (well at least until
you reconfigure the allowed values...) and the rules would evaluate the
request specific value based on the "allowed values" object. In this
case only the request specific parameter/value needs to be
inserted/retracted per request.
* I would rather use StatefulSession instead of stateless since I find
the API more flexible, are there any performance considerations I should
be aware of? If pooling is necessary I guess I must use the stateful
session. But if creating one session per request, are there any concrete
reasons for using the stateless session (besides the simpler API and
that I need to call dispose on the stateful session)?
Kind of hoping that the answer will be: "No, pooling will not be
necessary.", but any feedback about situations where it may be necessary
for best performance would be much appreciated.
Regards,
/Mikael
17 years, 1 month
RunTime Problem With Drools 4.0.3
by prateek.katiyar@wipro.com
Hello all,
I am using Drools 4.0.3.
In my application I have one singleton class to validate the input parameters. Also I am using one commonfunction.xml file which has all the functions for the applications e.g.
<function return-type="boolean" name="validateDate">
<parameter identifier="date" type="String" />
<parameter identifier="datepattern" type="String" />
<body>
// System.out.println(" validateDate date "+date);
// System.out.println(" validateDate datepattern "+datepattern);
if(date == null || date.trim().equals(""))
return(true);
SimpleDateFormat sdf = new SimpleDateFormat(datepattern);
Date testDate = null;
try{
testDate = sdf.parse(date);
}catch (ParseException e){
return(true);
}
if (!sdf.format(testDate).equals(date)){
return(true);
}
return(false);
</body>
</function>
I am loading this commonfunction.xml file only once in the constructor throughout the application. Also I have some specific rules for each module in my application.
One of the module is AirlineDemo.For this module I have various rules as source and destination can not same, departure date should be proper etc.
Now when I am running my application I am getting the ClassNotFoundException .
Please give me advice how can I remove this exception?
I am attaching the rule file and the description of the exception.
With Regards
Prateek
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
17 years, 1 month
RunTime problem with Drools 4.0.3
by prateek.katiyar@wipro.com
Hello all,
I am using Drools 4.0.3.
In my application I have one singleton class to validate the input parameters. Also I am using one commonfunction.xml file which has all the functions for the applications e.g.
<function return-type="boolean" name="validateDate">
<parameter identifier="date" type="String" />
<parameter identifier="datepattern" type="String" />
<body>
// System.out.println(" validateDate date "+date);
// System.out.println(" validateDate datepattern "+datepattern);
if(date == null || date.trim().equals(""))
return(true);
SimpleDateFormat sdf = new SimpleDateFormat(datepattern);
Date testDate = null;
try{
testDate = sdf.parse(date);
}catch (ParseException e){
return(true);
}
if (!sdf.format(testDate).equals(date)){
return(true);
}
return(false);
</body>
</function>
I am loading this commonfunction.xml file only once in the constructor throughout the application. Also I have some specific rules for each module in my application.
One of the module is AirlineDemo.For this module I have various rules as source and destination can not same, departure date should be proper etc.
Now when I am running my application I am getting the ClassNotFoundException .
Please give me advice how can I remove this exception?
I am attaching the rule file and the description of the exception.
With Regards
Prateek
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
www.wipro.com
17 years, 1 month
Re: [rules-users] 'or' with predicate/return val/inline eval with property issue?
by Michal Bali
Hi Edson,
Slovakia. Beer would be nice ;)
I'll wait for 4.0.4 release. I'm currently using 'eval' (not inline) as a workaround.
Thanks again for your effort.
Michal
----- Original Message ----
From: Edson Tirelli <tirelli(a)post.com>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Wednesday, 21 November, 2007 6:36:17 PM
Subject: Re: [rules-users] 'or' with predicate/return val/inline eval with property issue?
Michal,
Where are you from? We should pay you a beer for this bug report... :)
Looked like a simple thing, but it was the most annoying bug I had to deal with in a long time. :(
Thanks for reporting. It is fixed and will be released in
4.0.4 and 4.1.0.
If you want, while 4.0.4 is not released, you can build it yourself from here: http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/
[]s
Edson
2007/11/21, Michal Bali <michalbali(a)yahoo.ie>:
Hi Edson,
I've created new JIRA issue -
JBRULES-1337
Thank you for your time on this.
Regards,
Michal
----- Original Message ----
From: Edson Tirelli <
tirelli(a)post.com>
To: difranr(a)alumni.pitt.edu; Rules Users List <
rules-users(a)lists.jboss.org>
Sent: Wednesday, 21 November, 2007 12:48:54 PM
Subject: Re: [rules-users] 'or' with predicate/return val/inline eval with property issue?
Ronald,
In my tests, it works if you use a
simple constraint. The problem only happens with constraints that use semantic code.
I tracked down the problem and it is in the LogicTransformer that is used when an "or" CE is present.
[]s
Edson
2007/11/21, Ronald R. DiFrango <
ron.difrango(a)gmail.com>:
One question do you get different reslts if you do the folowing for the first rule:
Message( message == "somethingDifferent" ) # this should never match
All I did was eliminate the eval and the explicit call to equals
On Nov 21, 2007 4:05 AM, Michal Bali <
michalbali(a)yahoo.ie> wrote:
Hi,
I have following rule that should never fire, but it does :)
package com.sample
import com.sample.DroolsTest.*
;
rule "ruleThatShouldNeverFire"
when
Message( eval("somethingDifferent".equals(message)) ) # this should never match
SomeBeanA( ) or SomeBeanB( )
then
System.out.println( drools.getRule().getName() + " fired and shouldn't" );
end
stateful ruleSession with following
insertions:
Message message = new Message();
message.setMessage( "Hello World" );
workingMemory.insert( message );
workingMemory.insert( new SomeBeanA() );
workingMemory.insert( new SomeBeanB() );
It behaves the same way if we use predicates or retun values:
#Message( msg : message -> ("somethingDifferent".equals (msg)) ) # this should never match
#Message( message == ("somethingDifferent".equals (message)) ) # this should never match
It looks like the AlphaNode is missing from
the Rete network.
Tested with Drools 4.0.3. Java build 1.5.0_11-b03.
Any ideas if this is a bug or am I doing something wrong?
Thanks.
Regards,
Michal
Send instant messages to your online friends
http://uk.messenger.yahoo.com
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
Send instant messages to your online friends
http://uk.messenger.yahoo.com
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @
www.jboss.com
Send instant messages to your online friends http://uk.messenger.yahoo.com
17 years, 1 month