Look up for KnowledgeAgent
by Riyaz Saiyed
Hi,
Is it possible to look-up for registered knowledge agent?
Basically, I want to register the agent on sever start-up via start up
listener. This agent will connect to remote guvnor server through which I
will manage application rules.
For any incoming request, I’ll look up for the agent, get knowledge base,
create new stateless session and invoke execute method on that session
object for passed request parameters.
Please let me know if any one has better idea/design to achieve this.
Thanks,
Riyaz
--
View this message in context: http://drools.46999.n3.nabble.com/Look-up-for-KnowledgeAgent-tp2931764p29...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
Effect of KnowledgeAgent reload on currently running rules
by Jamie Shaw
If I use the KnowledgeAgent with the 'drools.agent.newInstance' property set to 'false' to automatically reload my KnowledgeBase when resources in the changeset are updated, what happens to any existing sessions when the agent detects changes and reloads the KnowledgeBase? Do they continue to use the old rules or are they somehow reloaded in midstream? What adverse effects might I see?
I ask because I'm trying to rework some existing classes that were written to facilitate the loading and caching of KnowledgeBases created in different ways - e.g. loading decision tables, loading .drl and .rf files in the traditional manner, loading .drl and .rf files using an agent. I'd like to be able to grab a KnowledgeBase from the cache regardless of how it was created, create a session from it, and fire all of the rules, but I'm concerned about cached KnowledgeBases created by KnowledgeAgents. If I set the newInstance property to 'true', my cached KnowledgeBase will never see the updates. If I set it to 'false', my cached KnowledgeBase should see the changes, but I'm concerned about the behavior in any currently running sessions.
FYI - the classes were originally written using the Drools 4.07 RulesAgent for caching RuleBases that needed to be automatically reloaded. It seems to be working as expected. I'm trying to update those classes to use Drools 5.1 classes instead.
Thanks,
Jamie
14 years, 11 months
drools-server
by Abhay B. Chaware
Hi
I am trying to get the default drools-server.war (drools-5.1.1-server.war to be specific ) to work on tomcat.
When I access http://localhost:8090/drools-5.1.1-server/kservice/rest , I am getting "No service found" in the browser and in the console,
=================================
May 18, 2011 3:43:44 PM org.apache.cxf.transport.servlet.ServletController invoke
WARNING: Can't find the request for http://localhost:8090/drools-5.1.1-server/kservice/soap's Observer
=================================
I am able to pass the deployment of the war file and tomcat starts fine. No errors related to Spring context etc, and I also see the line in the log :
=================================
INFO: Deploying web application archive drools-5.1.1-server.war
INFO 18-05 15:42:36,280 (ContextLoader.java:initWebApplicationContext:189) Root WebApplicationContext: initialization started
May 18, 2011 3:42:48 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be /kservice/rest
DEBUG 18-05 15:42:49,146 (ContextLoader.java:initWebApplicationContext:204) Published root WebApplicationContext as ServletContext attribute with name [org.springframework.web.context.WebApplicationContext.ROOT]
INFO 18-05 15:42:49,146 (ContextLoader.java:initWebApplicationContext:209) Root WebApplicationContext: initialization completed in 12866 ms
May 18, 2011 3:42:49 PM org.apache.cxf.transport.servlet.CXFServlet updateContext
INFO: Load the bus with application context
May 18, 2011 3:42:49 PM org.apache.cxf.transport.servlet.AbstractCXFServlet replaceDestinationFactory
INFO: Servlet transport factory already registered
=================================
14 years, 11 months
Drools and threads
by Abhay B. Chaware
Hi
I have few questions about Drools.
Are rules compiled, partially compiled or interpreted ?
When I call fireAllRules(), does it ( or can it ) create a new thread that runs parallely or the operation is sequential and the caller program HAS TO wait till all rules execution is done ?
Also, How is the application data integrity guarantied? E.g. what happens when some of the facts are changed in middle of rules being executed .. ? what should happen ?
-abhay
14 years, 11 months
Is it possible to affect load order of rules?
by Martin, Matthias
Hello,
in our project we've to know, which rules have already been checked, regardless whether or not the rule gets activated and hence put on the agenda. Is there any possibility to affect the order, in which the drools engine reads and checks the LHS of rules? I suppose the assignment of a salience value has no effect on the load order and is rather a mechanism for conflict resolving, when a rule is about to be fired.
Background for this demand explained in an nutshell:
We use salience for conflict resolving. The conflicting rule with the highest salience value should be fired, but the others with minor salience values mustn't! In our scenario it can occur, that two (or more) rules might conflict at runtime. Therefore we want to perceive, which rule for which fact has already been checked, actually if it gets never activated on the agenda.
Example:
rule "morespecific"
salience 100
when myObj(variant = Variants.SPECIFIC_1 && fee < 10)
then....
end
rule "general"
salience 30
when myObj(fee < 100)
then....
end
If I set the value for variant to Variants.SPECIFIC_1 and the fee value to 30, for example, the first rule will never make it to the agenda but the second one does and is actually getting fired because it doesn't care about the variants value and 30 is less 100.
We want to perceive the already performed check for "morespecific" for a specific object und halt the execution of "general".
Any suggestions are welcome!
Regards,
Matthias Martin
14 years, 11 months
How can I access the updated JAR file in DRL file ???
by Vijeth Raj
Hi ,
Recently i was working on a drools project where i came across certain
issues and i need some help.
In my project i access jar at runtime by making use of the
URLClassLoader.Here is the code :
Object object=*null*;
Class myclass=*null*;
URL jarPath=*null*;
*try*{
jarPath=*new* File("lib/Billing.jar").toURI().toURL();
URLClassLoader loader = *new* URLClassLoader(*new* URL[] { jarPath },*
ClassLoader.*getClassLoader());
myclass = loader.loadClass("dynamicclasses.Billing");
object = myclass.newInstance();
}
*catch* (Exception e) {e.printStackTrace}
After getting the class instance I will set the values and pass the object
to my drools class
new DroolsClass().fireRules(object);
The drools class contain the following code :
public class DroolsClass {
*public* *void* fireRules(Object object){
*try* {
KnowledgeBase kbase = *readKnowledgeBase*();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.*newFileLogger*(ksession, "test");
ksession.insert(object);
ksession.fireAllRules();
logger.close();
} *catch* (Throwable t) {
t.printStackTrace();
}
}
*private* *static* KnowledgeBase readKnowledgeBase() *throws* Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.*
newKnowledgeBuilder*();
kbuilder.add(ResourceFactory.*newFileResource*(
"./rulefiles/testing.drl"), ResourceType.*DRL*);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
// *------ some code*
KnowledgeBase kbase = KnowledgeBaseFactory.*newKnowledgeBase*();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
*return* kbase;
}
Next I have a drl file testing.drl which is present in the file directoty
and which accesses the same class dynamicclasses.Billing which is present in
Billing.jar
Here is the drl file content :
*import* dynamicclasses.Billing;
*rule* "rule 3"
*salience* 10
*dialect* "mvel"
*no-loop* *true*
*when*
m : Billing(bplan=="plan1")
*then*
System.out.println("You have opted for plan1");
*end*
* *
The problem I encounter is when the jar i.e Billing.jar get updated at
runtime the drl file i.e testing.drl
The following things i am trying to do.
1) I will create jar at runtime and update it if required.
2) I will create a drl file at runtime which will import the class present
in the jar i.e. dynamicclasses.Billing
I am able to access the updated jar contents in my java class ussing
URLClassLoader .But once i pass the object to my drools class i get the
following exception
Unable to resolve ObjectType 'Billing' : [Rule name='rule 3']
Error importing : 'dynamicclasses.Billing'
*java.lang.IllegalArgumentException*: Could not parse knowledge.
If i restart my application i get no exception since the jar is already
present but the object doesn't seem to pass to the drl and i get no result.
I made the following adjustment to the code :
URLClassLoader loader = new URLClassLoader(new URL[] { jarPath
},this.getClass().getClassLoader());
Here I get the same exception initially. But after I restart my application
it works fine and the rule get fired and I will get the result.
But again if I update the jar it will access only the previous content.
So it’s clear that the DRL file is not able to access the jar initially or
even after updating.
Is there any way so that I can make it work?
Thanks.
--
Thanks & Regards,
Vijeth Raj K
Email : vijethrajk(a)gmail.com
14 years, 11 months
Complicated Grant Permissions Logic
by ginni
Hi,
I am new to Drools and would just like to understand how to do what I am
trying to do. This syntax does not work, and I am not sure how to make it
work. I want permission granted if:
User is Librarian
OR user is Submitter OR user is Requester AND requestSubmitted is false
AND
requestCancelable is true
This syntax requires the user to be both librarian AND submitter or
requester.
when
$perm: PermissionCheck(target == "libraryRequest", action ==
"cancelRequest", granted == false)
RequestState($requestCancelable: requestCancelable, $requestSubmitted:
requestSubmitted)
Role(name == "APP_LIBRARY REQUESTS_LIBRARY STAFF")
eval($requestCancelable == true ||
($submitter.getBadgeNumber().equals($userBadge) ||
$requester.getBadgeNumber().equals($userBadge) && !requestSubmitted))
)
Any help would be greatly appreciated!!
Thanks,
Ginni
--
View this message in context: http://drools.46999.n3.nabble.com/Complicated-Grant-Permissions-Logic-tp2...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 11 months
drools-spring drools-grid-impl dependency
by Tommy Odom
Hi,
I was attempting to try an upgrade from drools 5.1.1 today to 5.2.0.M2 but I ran into a problem with using the drools-spring artifact. Since drools-spring needs access to the GridNode it has a dependency on drools-grid-impl which in turn has dependencies on hibernate & JPA 1.0 and includes a persistence.xml file. I was able to work around the hibernate and JPA 1.0 dependencies using maven exclusion rules but it appears that the included persistence.xml is causing problems with my own configuration locating its persistence unit.
Would it be possible to extract the grid classes that drools-spring is dependent on out into a drools-grid artifact that instead of depending on the full impl? Either that or does anyone have any suggestions for making sure my persistence.xml in my WAR takes precedence over the one in the JAR?
Thanks!
14 years, 11 months