How to include Maven repo jar in kbase using KModuleBeanFactoryPostProcessor
by Shrinath Managuli
Hi drools,
Using org.kie.spring.KModuleBeanFactoryPostProcessor, how to include the packages for kbase1 either from Maven repository or through an HTTP call (instead of include packages from class path folder)
Something like,
<kie:kbase name="kbase1" packages="org.test.helloword">
<kie:ksession name="ksession1" type="stateless" />
</kie:kbase>
I had looked into KModuleBeanFactoryPostProcessor and ClasspathKieProject.createInternalKieModule(), it seems all the packages are loaded from class path alone.
Also, if including the packages from Maven repository or through an HTTP URI is feasible, then how can we do a scanner for refreshing the packages?
Please share your views on this?
Thanks,
Shrinath
[Aspire Systems]
This e-mail message and any attachments are for the sole use of the intended recipient(s) and may contain proprietary, confidential, trade secret or privileged information. Any unauthorized review, use, disclosure or distribution is prohibited and may be a violation of law. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
11 years, 6 months
Drools spawning a lot of JIT threads
by Frank Pavageau
Hi.
I'm using Drools 5.5 in a web application, upgraded a few months ago from
5.1. When starting multiple instances of the application on a server *at
the same time*, I recently noticed some problems with the JVMs complaining
of not being able to create native threads.
The stack trace led to Drools, and more specifically MvelConstraint
submitting JIT tasks to an Executor through its jitEvaluator() method. The
Executor is created by ExecutorProviderImpl and is a basic
CachedThreadPool, which means it can create an unbounded number of threads
(which then die after idling for a minute). In my case, it apparently meant
around 900 threads per JVM, which multiplied by the number of running JVMs
saturated the OS for a short while.
Has anyone else been bitten by this? Should there be a more reasonable
default implementation and should I create an issue for this?
I then have a question related to how I fixed this: I created my own
implementation of ExecutorProvider by extending ExecutorProviderImpl and
creating a ThreadPoolExecutor with an upper bound on the number of threads
and a LinkedBlockingQueue to queue the tasks when all the threads are
already busy. That works fine, the only problem is telling Drools to use my
implementation: the only way I've found is by
calling ServiceRegistryImpl.getInstance().registerLocator().
ServiceRegistryImpl implements ServiceRegistry, but the interface doesn't
seem to be exposed through Drools' more public API; it seems a bit wrong to
call the implementing class directly to get its instance, especially given
the Javadoc which states "This is an internal class, not for public
consumption". Am I missing something?
Regards,
Frank
11 years, 6 months
Re: [rules-users] java.lang.NoSuchMethodError thrown in drools api
by DE_Azrael
Good morning !
@snak: That was the first hint I found during my investigation but it could
not be the failure.
It could not be a problem of version incompatibility. As I wrote the
transaction was working 4 times and failed at the 5th transaction
(reproducable).
If it would be a problem of incompatibility no transaction could be
successful.
>From the error stack I was wondering why it was saying
ConditionEvaluatorf4a3f354729241ac8370890200fdf2d8.evaluate(Unknown Source)
Guess this class is generated automaticly and the source that is missing at
this point is the kbase.
I checked again the initialisation of kbase and I found a failure.
The kbase is defined as static and is beeing initialised with the first
transaction. Additionaly it's beeing updated every few minutes.
After I corrected this the failure disappear.
I did the following changes:
*old code:*
if ((knowledgeSetupTimestamp + timeInMillis) < System.currentTimeMillis())
ageReload = true;
if ((kbase == null) || ageReload) {
synchronized (DroolsHelper.class) {
if ((kbase == null) || ageReload) {
.........
}
}
}
*new corrected code:*
if ((kbase == null) || (knowledgeSetupTimestamp + timeInMillis <
System.currentTimeMillis())) {
synchronized (DroolsHelper.class) {
if ((kbase == null) || (knowledgeSetupTimestamp + timeInMillis <
System.currentTimeMillis())) {
.........
}
}
}
I'm still a bit puzzled about the reported failure and it would be great if
someone could explain me this behaviour.
Thanks a lot !
Cheers 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, 6 months
KieScanner with Maven 3
by Maxime Falaize
Hello,
Does the KieScanner support Maven 3? I noted that LATEST, RELEASE and
SNAPSHOT metaversions for Maven are no longer supported by Maven 3 so do I
have to understand that we cannot use the KieScanner with Maven 3?
By the way I noted that if I set my KieContainer with a LATEST version, the
KieScanner systematically redeploy my JAR as the KieScanner compare the
real version with "LATEST". I've seen that there were some changes in the
KieScanner in the 6.1.0, did you fix it? I can't test right now because I
face a rule compilation problem with the new 6.1.0 version and I still have
to figure this out.
Regards
--
Maxime FALAIZE
11 years, 6 months
java.lang.NullPointerException in simple example
by ahgiovanini
Hi guys!
I'm new in the world of jboss and drools and I'm making some simple examples
that existing on
https://github.com/droolsjbpm/drools/tree/master/drools-examples-api
Now, I'm studing the CashFlow example and in my project when I run it, I
receive a error message saying:
Exception in thread "main" java.lang.NullPointerException
at com.sample.CashFlowMain.main(CashFlowMain.java:30)"
I don't know the why this message, because I set the acp at lines 20 and 21.
Someone would help me please?
Thanks
package com.sample;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.rule.FactHandle;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CashFlowMain {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
KieContainer kc =
KieServices.Factory.get().getKieClasspathContainer();
KieSession ksession = kc.newKieSession("CashFlowKS");
AccountPeriod acp = new AccountPeriod();
acp.setStart(date("2013-01-01")); // set acp - line 20
acp.setEnd(date("2013-03-31")); // set acp - line 21
Account ac = new Account(1, 0);
CashFlow cf1 = new CashFlow(date( "2013-01-12"), 100,
CashFlowType.CREDIT, 1 );
CashFlow cf2 = new CashFlow(date( "2013-02-2"), 200,
CashFlowType.DEBIT, 1 );
CashFlow cf3 = new CashFlow(date( "2013-05-18"), 50,
CashFlowType.CREDIT, 1 );
CashFlow cf4 = new CashFlow(date( "2013-03-07"), 75,
CashFlowType.CREDIT, 1 );
FactHandle fh = ksession.insert(acp);
ksession.insert( ac );
ksession.insert( cf1 );
ksession.insert( cf2 );
ksession.insert( cf3 );
ksession.insert( cf4 );
ksession.fireAllRules();
acp.setStart(date( "2013-04-01"));
acp.setEnd(date( "2013-06-31"));
ksession.update(fh, acp);
ksession.fireAllRules();
}
public static Date date(String str) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.parse( str );
}
}
--
View this message in context: http://drools.46999.n3.nabble.com/java-lang-NullPointerException-in-simpl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Re: [rules-users] A employee roster like case - OptaPlanner
by ge0ffrey
Sounds like a typical OptaPlanner problem.
Domain model:
- CareTaker
- OldPerson
- Day
- Visit(OldPerson, Day)
- @PlanningEntity VisitAssignment (Visit, @PlanningVariable CareTaker)
Using the OptaPlanner employee rostering example:
- CareTaker == Employee
- OldPerson == ShiftType
- Day == ShiftDate
- Visit(OldPerson, Day) == Shift (ShiftType, ShiftDate)
- @PlanningEntity VisitAssignment (Visit, @PlanningVariable CareTaker) ==
ShiftAssignment (Shift, @PlanningVariable Employee)
--
View this message in context: http://drools.46999.n3.nabble.com/A-employee-roster-like-case-tp4029352p4...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 6 months
Re: [rules-users] (Hot?) rules production deployment
by Pykhtin, Alex
Thank you again, Steve.
We need to make all kind of changes to the rules, however, small changes are more frequent than significant ones. So, every time we are deploying a new rule, there is a risk of it either not compiling or failing properly follow business logic.
We can trust users with any changes, however, moving the code to production is a big deal. This should be vetted by an authority figure, and there must be a simple and transparent rollback plan.
Yes, we want to be very risk-averse.
Ideally, we would like to have:
1. A staging environment where automation tests are run;
2. A change can be deployed to production only if all automation tests have passed;
3. Some kind of administration console from which a change can be manually deployed to production (via uploading to production Maven repository or in some other way);
4. Production Drools system picking up new changes without interruption of service;
5. Production console function allowing a one-click rollback of a recent change;
Alex
P.S. Sorry, it looks like I have not mastered proper replying to a forum thread.
> Pretty much correct.
>
> re. 5 - It depends on what you mean by it becoming clear that a release is a bad one.
>
> I have tended to code up my own knowledge base reloads and check for errors, but I'm pretty sure that if your rules don't compile, then neither the KnowledgeAgent nor the KieScanner will deploy them. If you use Guvnor, then your project will not be built and packaged if the rules don't compile.
>
> However, if the problem is that the new rules are just 'wrong' within your domain, then it's hard to think of any way in which that could be detected > automatically, other than by you yourself writing the validation.
>
> To help with this, I have previously set up a FitNesse server which would load in the latest rules and evaluate them, ensuring that output expectations are met. However, no such test suite is perfect. It may be that a change is made which needs a new test to evaluate it. If that test is not written, then the suite of tests still passes.
>
> Similarly, you can write unit tests for the build. You can deploy to a staging server, where the rules can be evaluated with as-live data, so that you can regression test the rules service in isolation from the rest of your application.
>
> Looking at rollback, in one Guvnor-based system, I have the users take a snapshot for each rules deployment. They then copy that snapshot to an "approved" snapshot. This way, rollback is just a case of copying the previous version to "approved" and deploying that. The users are legal and back office operations teams, and they are pretty efficient at following this process these days.
>
> However, in the end it comes down to things like:
> What kind of rule changes do users typically make? i.e. Are they just changing some numbers in existing decision tables?
> Can you trust the users to only make non-risky changes? Guvnor won't stop them from altering the structure of decision tables, or adding new non-decision-table rules.
> How risk-averse are you?
>
> Steve
11 years, 6 months