Reloading knowledge base from another thread
by gkalabin
Hi everybody!
I'm using Drools 5.4.0.Final.
I'm checking changes in knowledge repository and if there is any - update
knowledge base.
The changes listening I perform like described in article:
https://community.jboss.org/wiki/PublishDroolsArtifactsFromAProductionEnv....
Updating knowledge base code:
private static final Environment JBPM_ENVIRONMENT =
KnowledgeBaseFactory.newEnvironment();
private static final KnowledgeSessionConfiguration JBPM_CONFIG;
static {
JBPM_ENVIRONMENT.set(EnvironmentName.ENTITY_MANAGER_FACTORY,
Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"));
JBPM_ENVIRONMENT.set(EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager());
JBPM_ENVIRONMENT.set(EnvironmentName.GLOBALS, new
MapGlobalResolver());
Properties properties = new Properties();
properties.put("drools.processInstanceManagerFactory",
"org.jbpm.persistence.processinstance.JPAProcessInstanceManagerFactory");
properties.put("drools.processSignalManagerFactory",
"org.jbpm.persistence.processinstance.JPASignalManagerFactory");
JBPM_CONFIG =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);
}
....
private static StatefulKnowledgeSession createSession() {
StatefulKnowledgeSession session =
JPAKnowledgeService.newStatefulKnowledgeSession(readKnowledgeBase(),
JBPM_CONFIG, JBPM_ENVIRONMENT);
session.getWorkItemManager().registerWorkItemHandler("Human Task",
new CommandBasedWSHumanTaskHandler(session));
return session;
}
When I load changes from main thread (on startup, for example) everything is
fine, but when I try to reload knowledge base from another thread it falls
with exception ( full stacktrace
<http://drools.46999.n3.nabble.com/file/n4020008/error_log.txt> ):
15:00:56,420 ERROR [org.drools.persistence.SingleSessionCommandService]
(Timer-14) Could not commit session: java.lang.NullPointerException
at
org.drools.persistence.jta.JtaTransactionManager.getStatus(JtaTransactionManager.java:205)
[drools-persistence-jpa-5.4.0.Final.jar:5.4.0.Final]
How can I solve it?
Thank you for your attention. Have a good day!
--
View this message in context: http://drools.46999.n3.nabble.com/Reloading-knowledge-base-from-another-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
How to integrate Drools application with Servlet
by zeeshan
Hi All !
I have an existing web application "Bonus Calculation Management System"
which has been developed in servlet and Hibernate which is interacting with
DB. I have developed a product in Drools using Struts. Now the task is I
have to integrate this drools product in the Existing Servlet application. I
have integrating it converting Struts to Servlet. But it is giving this
exception about my Rule File :
*
com.drools.action.PolicyAction
hurrrrrrrrrrrrrr
java.io.FileNotFoundException: Cannot find rule file:Sample.drl
at com.drools.facts.RuleRunner.loadRuleFile(RuleRunner.java:89)
at com.drools.facts.RuleRunner.loadRules(RuleRunner.java:67)
at com.drools.facts.RuleRunner.getStatefulSession(RuleRunner.java:227)
at com.drools.facts.RuleMain.main(RuleMain.java:46)*
*In my Servlet class I have written like this :* public int
calculate(HttpServletRequest req, String schId,String schStepID, Date
clcFrDate, Date clcToDate,String runNo)
{
System.out.println("hurrrrrrrrrrrrrr");
InputFormBean inputFormBean=new InputFormBean();
inputFormBean.setFromDate(clcFrDate.toString());
inputFormBean.setToDate(clcToDate.toString());
String fromDateArray[]=inputFormBean.getFromDate().trim().split("/");
String toDateArray[]=inputFormBean.getToDate().trim().split("/");
inputFormBean.setFromDateArray(fromDateArray);
inputFormBean.setToDateArray(toDateArray);
RuleMain ruleMain=new RuleMain();
try {
ruleMain.main(inputFormBean);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
*In the RuleMain.java* : public class RuleMain extends HttpServlet {
private final String[] RULES_FILES8 = new String[] {"Sample.drl"}; // *I
also tried : com.drools.rules/Sample.drl but dint work*
static HashMap<Integer, Double>agntAPEMap=new HashMap<Integer, Double>();
public void main(InputFormBean inputFormBean) throws Exception {
HashMap<String, Object> globals = new HashMap<String, Object>();
//globals.put("index", new Index(0));
StatefulSession statefulSession=new
RuleRunner().getStatefulSession(RULES_FILES8,null,null, globals, null);
......
........
Thanks !!!
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-integrate-Drools-application-wit...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
Planner: Vehicle Routing, but with return to home after last delivery
by jimirn
Hi all,
I have changed the Vehicle Routing example to suit my domain model.
My domain is:
- Consultant (the person that will drive to a DeliveryPlace and spent some
time there, each Consultant has a max total time available, implements
Appearance)
- DeliveryPlace (the place where a Consultant will drive to and spent some
time making a delivery, implements Appearance)
- Location (a Consultant has a home and a DeliveryPlace has a location)
I need the soft constraints to take into account returning from last
DeliveryPlace to the home location of the Consultant.
But how do I know if a DeliveryPlace is the last one so I can add that to
the rule ?
Right now I have a rule that just takes each DeliveryPlace and calculates
minutes to previousAppearance:
rule "minutesToPreviousAppearance"
when
$deliveryPlace : DeliveryPlace(previousAppearance != null,
$minutesToPreviousAppearance : minutesToPreviousAppearance)
then
insertLogical(new
IntConstraintOccurrence("minutesToPreviousAppearance",
ConstraintType.NEGATIVE_SOFT,
$minutesToPreviousAppearance,
$deliveryPlace));
end
--
View this message in context: http://drools.46999.n3.nabble.com/Planner-Vehicle-Routing-but-with-return...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
adding de-serialized packages to the rulebase takes 7 minutes time.
by subba
Hi,
I am using drools 5.0.0 CR1 on sun sparc machine with JRE 1.6.0_12. The JVM
has 2GB heap and 256 permGen settings.
Recently I have noticed that the adding the deserialized package to the
rulebase takes almost 7 minutes time.
The serialized cache files contains 4000 rules and the file size is 40MB.
The de-serialization is pretty quick but adding this package to the rulebase
is taking lot of time.
Other observations:
=============
1. The the task on windows PC takes lesser time.
2. During addpackage method execution, I had observed lots of Garbage
collection happening though there is plenty of heap available.
Can you please suggest a way to improve this task timing ?
Regards.
Subba.
--
View this message in context: http://drools.46999.n3.nabble.com/adding-de-serialized-packages-to-the-ru...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
Pattern Example
by thano
Hi,
I am struggling to understand the concept of patterns. I have the following
code which I would like as a generic threshold pattern. I have been told
that it is not a pattern- thanks
rule “DD”
when
# calculate the average requests made over 10 days
$service: Service( )
Number ( $ averageRequest : doubleValue )
from accumulate
( RequestCompletedEvent (fromService = = $service,
$request : request ) over window : time (10d)
from entry-point RequestStream,
average ( $request) )
# check if the requests made in the last 60 seconds are higher than
then the threshold value
$r : RequestCreatedEvent ( fromService = = $service,
Request > $averageRequest over
Window : time (60s)
from entry-point RequestStream
then
# do something
end
--
View this message in context: http://drools.46999.n3.nabble.com/Pattern-Example-tp4019946.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
Getting Names of all the rules from the excel
by himansu.nayak
Hi,
i am using drools rule template. all my rules data are in a separate excel
file.
the first row of the excel is taken as rule name in my template file. My
current requirement
needs me to get the name of all the rules from the excel file.
i am using drools.getRule().getName() but its of no use as this only work if
the specific rule has to be executed.
is there any other api in drools which gives me all the rules name from the
excel??
else i have to write an Adapter to do the same from the excel.
Thanks...
Himansu
-----
Thanks...
Himansu
--
View this message in context: http://drools.46999.n3.nabble.com/Getting-Names-of-all-the-rules-from-the...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months
Re: [rules-users] Classcast exception in Drools ant task
by Mutyala Suresh kumar
Yes, i have the correct mvel jar in my classpath. "mvel2-2.1.0.drools16.jar" is the jar which i copied from the drools-5.4.0 zip file.
Thanks and Regards,
Suresh Kumar Mutyala
(+91) 9032485123
________________________________
Message: 1
Date: Fri, 21 Sep 2012 09:47:59 -0700 (PDT)
From: lhorton <LHorton(a)ABCLegal.com>
Subject: Re: [rules-users] Classcast exception in Drools ant task
To: rules-users(a)lists.jboss.org
Message-ID: <1348246079889-4019894.post(a)n3.nabble.com>
Content-Type: text/plain; charset=us-ascii
I checked the binaries for 5.4.0.FINAL and the mvel jar is not named
mvel2.jar. Are you sure you have the correct mvel jar in your classpath for
5.4.0?
--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-Classcast-exception-in-Droo...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 3 months