Insert a fact into drools server from a web application or java application
by kkelleyjr
Ok, I have read the documentation like a million times. I have looked at all
the examples. Yet I still can not figure out how to add a fact to the drools
server ksession1 from a web application or a java application. I have got
the server to work. I have even got the soapUI to work. now I want to add a
fact from my own client.
My issue is that I need to add a facts that has maps and list in the pojo.
how can I just add the pojo to the ksession1? Is there an example that is
out there that I have not found?
It seems simple, but I just do not understand... can someone provide some
additional help, please?
--
View this message in context: http://drools.46999.n3.nabble.com/Insert-a-fact-into-drools-server-from-a...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Drools Execution Server memory leak?
by Mike Reynolds
Using: 5.2.0.Final of drools camel server , JSON api, and a Stateless Session
We are making JSON calls to the camel (execution) server. Our
end-to-end unit tests pass. Our load tests, however, show that memory
is never reclaimed after each call to the rules engine. After parsing
through a heap dump, we see the following path taking up over 800 meg of
memory:
(kagent) KnowledgeAgentImpl$ChangeSetNotificationDetector
> (kbase) KnowledgeAgentImpl
>> (ruleBase) KnowledgeBaseImpl
>>> (eventSupport) ReteooRuleBase
>>>> (listeners) RuleBaseEventSupport
>>>>> (array) CopyOnWriteArrayList
>>>>>> ReteooWorkingMemory (around 864K of these)
The rule base is very small and simple - this is only a problem during a load test (or over the course of a weeks worth of calls). We make the following call 10K times:
{
"batch-execution": {
"lookup": "ksession1",
"commands": [
{
"insert": {
"out-identifier": "tc_1",
"object": {.....}
}}]}}
The knowledge-services.xml configures :
- kagent id="agent1" kbase="kbase1" new-instance="true"
- ksession id="ksession1" type="stateless" kbase="kbase1" node="node1"
The rules just update the inserted "timecard" fact.
Because I'm using a stateless session, I don't think I need to
dispose of the agent...and I don't think there is a way to call dispose
using the json/Execution Command api.
We are calling the camel (execution) server from a non-java
environment to process employee timecards entries and evaluate for
overtime calculations.
Thanks!
Mike
13 years, 3 months
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[
by bhavindalal
Hello,
I am new to Drools. On starting to execute a simple program, eclipse gives
the following stacktrace as error. I even included the org.eclipse.jdt that
comes with eclipse, but it is still giving me error. Anybody please suggest
the problem. I am using Drools 5.0 and its dependencies and Eclipse Helios
java.lang.NoSuchMethodError:
org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/CategorizedProblem;
at
org.drools.commons.jci.compilers.EclipseJavaCompiler$3.acceptResult(EclipseJavaCompiler.java:321)
at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:335)
at
org.drools.commons.jci.compilers.EclipseJavaCompiler.compile(EclipseJavaCompiler.java:351)
at
org.drools.commons.jci.compilers.AbstractJavaCompiler.compile(AbstractJavaCompiler.java:51)
at
org.drools.rule.builder.dialect.java.JavaDialect.compileAll(JavaDialect.java:389)
at
org.drools.compiler.DialectCompiletimeRegistry.compileAll(DialectCompiletimeRegistry.java:56)
at org.drools.compiler.PackageRegistry.compileAll(PackageRegistry.java:74)
at org.drools.compiler.PackageBuilder.compileAll(PackageBuilder.java:690)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:653)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:290)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:488)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:25)
at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:40)
at com.sample.DroolsTest.main(DroolsTest.java:23)
Thanks
--
View this message in context: http://drools.46999.n3.nabble.com/org-eclipse-jdt-internal-compiler-Compi...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
how to update object modified by call to remote web service
by lhorton
We are at 5.2.0 Final
We recently moved our rules server (written in-house) to its own Tomcat
instance. Some of our existing rules call a service to modify facts. With
the move of the rules server, these calls to the service no longer happen in
the working memory of the rules server. The rule must now capture the
return from the call to the remote service, in order to see the changes made
by the remote service call.
Within the rule, this change is working fine. The RHS was:
applicationService.applyInstruction($step);
as above, the $step fact would not be updated within the rule WM now that
the service is called remotely. However, when I changed this to
$step = applicationService.applyInstruction($step);
then $step did have the changes(I am verifying this by writing debug info to
the log). BUT, the object that was passed in to execute() on the knowledge
session did NOT have the changes. I have tried several things to fix this.
one was to update($step) but this failed with "Update error: handle not
found for object," I assume because the fact handle changed in the object
returned from the service call.
I also tried some variations on retracting and inserting the step:
retract($step);
$step = applicationService.applyInstruction($step);
insert($step);
and also tried using a different variable name:
retract($step);
$step2 = applicationService.applyInstruction($step);
insert($step2);
update($step2);
both these above did not get errors, but also did not cause the updated
object to return from session.execute() call.
To summarize:
in a call to execute() on a stateless knowledge session, an object is passed
in
a rule fires that calls a remote service that modifies the object
within the rule, we catch the changed object that is returned from the
service call
within the rule, the changes to the object ARE visible
on the return from execute(), the changes are NOT visible
thanks for your help...
--
View this message in context: http://drools.46999.n3.nabble.com/how-to-update-object-modified-by-call-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Drools-Fusion : Inserting an Event in to an "entry-point" stream in the RHS of a rule?? Pls help
by Chetan Mahadev
Hi
Can we insert an Event in the RHS part of a rule to an entry-point?
basically i am trying to do this. Pls let me know if this is possible? if
not any alternative approaches? Any example would be useful pls
declare TransactionEvent
@role( event )
end
$tmp : TestClass()
$tmp.message == "TRUE"
then
TransactionEvent ev1 = new TransactionEvent (); // This should be
inserted in to an entry-pont "Temporal Reasoning" stream
ev1.setMessage("Temporal Reasoning")
insert (ev1) to entry-point "Temporal Reasoning"
end
rule "Temporal Reasoning"
$tmp : TransactionEvent ( message== "Temporal Reasoning") from entry-point
"Temporal Reasoning"
then
System.out.println("Rule fired due to entry point ");
end
Regds
Chetan
13 years, 3 months
Java 1.4 Application
by Sumeet Karawal
Hi All,
I have to use Drools in a Java Application with Java version 1.4
Can I use Drools 5.0 for that or do I have to use Drools 4.0.x version?
Please help me on this.
Thanks & Regards
Sumeet Karawal
Mailto: sumeet.karawal(a)tcs.com
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
13 years, 3 months
Condition syntax to access Map
by bolsover
I'm struggling with the syntax to access a mapped object - hoping that
someone can help with this..
I have the following condition in a rule:
$a : Answer(getAnswerData().get(0).getValue_str() == "Valves")
Answer is a pojo where answerData is a Map<Integer, AnswerData>
object.
AnswerData is also a pojo and has a String variable value_str.
Rule containing this condition complies but I get the following error when I
fireAllRules
[Error: null pointer or function not found: getValue_str]
[Near : {... getAnswerData().get(0).getValu ....}]
^
[Line: 1, Column: 1]
org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:997)
The method getValue_str() does exist in AnswerData as does getAnswerData()
in Answer and there are not any null values.
I'm assuming that autoboxing will correctly interpret .get(0) as an Integer
object.
Any ideas??
--
View this message in context: http://drools.46999.n3.nabble.com/Condition-syntax-to-access-Map-tp320442...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 4 months
Rule Task
by S.M.H.Jamali
Hello All
I create a simple JBPM Process by Eclipse Plugin that starts with a Script Task and after Script Task i want to add a Rule Task. In fact i want to fire a rule in my process to make a decision on the Gate Way node. I use Guvnor and JBPM Console to run my processes and after designing the processes i upload them to Guvnor.
My problem is : when i create a new instance of my process (in jbpm console) , first Script Task run fine , but execution of the process stops at Rule Task and no rule fired ! Am i missing something ?
Any Help Appreciated
S.M.H.Jamali
13 years, 4 months
Stateful vs. Stateless Session Performance
by Ryan R.
I have a usecase where I want to apply rules to messages that are received
and processed one message at a time.
I am thinking the stateless session matches this usecase. I was surprised
though to notice that the stateless session seemed to perform upwards of 10x
slower!
I am including the below source which illustrates my usage. The DRL file
used simply has one rule that does a simple modification on two fields.
There is some test code above this stuff that just pushes messages into the
plugin.
I am also including VisualVM profiling results. The top results are for the
stateful while the bottom are for the stateless. It looks like the stateless
performance is dominated by calls to ReflectionInstantiator.newInstance()?
StatelessKnowledgeSession Code:
public class DataConditionPlugin implements Plugin {
final KnowledgeBuilder kbuilder;
final StatelessKnowledgeSession ksession;
public DataConditionPlugin(String drlFileName) {
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(
ResourceFactory.newClassPathResource(drlFileName,
DataConditionPlugin.class),
ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile \""+drlFileName+"\".");
}
// get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();
// add the packages to a knowledgebase (deploy the knowledge packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
ksession = kbase.newStatelessKnowledgeSession();
}
@Override
public Object execute(Object message) {
ksession.execute(message);
return message;
}
}
StatefulKnowledgeSession Code:
public class DataConditionPlugin implements Plugin {
final KnowledgeBuilder kbuilder;
final StatefulKnowledgeSession ksession;
public DataConditionPlugin(String drlFileName) {
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(
ResourceFactory.newClassPathResource(drlFileName,
DataConditionPlugin.class),
ResourceType.DRL);
// Check the builder for errors
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors().toString());
throw new RuntimeException("Unable to compile \""+drlFileName+"\".");
}
// get the compiled packages (which are serializable)
final Collection<KnowledgePackage> pkgs =
kbuilder.getKnowledgePackages();
// add the packages to a knowledgebase (deploy the knowledge packages).
final KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
ksession = kbase.newStatefulKnowledgeSession();
}
protected void finalize() throws Throwable {
ksession.dispose();
};
@Override
public Object execute(Object message) {
FactHandle factHandler = ksession.insert(message);
ksession.fireAllRules();
Object o = ksession.getObject(factHandler);
ksession.retract(factHandler);
return o;
}
}
http://drools.46999.n3.nabble.com/file/n3208057/Screenshot-Java_VisualVM.png
--
View this message in context: http://drools.46999.n3.nabble.com/Stateful-vs-Stateless-Session-Performan...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 4 months
error resolving class name on imported class when loading package
by lhorton
I am getting an error when the knowledge agent loads a pkg. The rules source
file contains an import for a class:
com.abclegal.domain.task.FileDocumentsWithCourtTask
and the RHS of a rule makes a cast using the class name without fully
qualifying it:
((FileDocumentsWithCourtTask)$step.getTask()).addDocument($doc);
I see the following error when the package is loaded by knowledge agent:
Error creating bean with name 'workflowKnowledgeAgent': Invocation of init
method failed; nested exception is [Error: unable to resolve method using
strict-mode: java.lang.Object.FileDocumentsWithCourtTask()]
[Near : {... ((FileDocumentsWithCourtTask)$st ....}]
note in the error that the FileDocumentsWithCourtTask is not being resolved
according to the import statement. The really odd thing about this is that
it doesn't get the error all the time. Sometimes the package is loaded
without error.
I can probably resolve this by fully-qualifying the class name within the
RHS, but you are not supposed to have to do that if you put the
fully-qualified name in the import of the rule.
Any clue why this error might happen?
--
View this message in context: http://drools.46999.n3.nabble.com/error-resolving-class-name-on-imported-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 4 months