Facing problem in ResourceChangeScanner
by Saurabh
Hi ,
I am trying to understand KnowledgeAgent functioality.
but i am facing following issue
ResourceChangeScanner is scanning the change resource and building the
Knowledgebase but still firing previous rules.
I am using these line of codes
File fxml = new File("change-set.xml");
kbase = KnowledgeBaseFactory.newKnowledgeBase();
ResourceChangeScannerConfiguration sconf =
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "2");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.scanDirectories", "true");
aconf.setProperty("drools.agent.useKBaseClassLoaderForCompiling", "true");
aconf.setProperty("drools.agent.scanResources", "true");
aconf.setProperty("drools.agent.newInstance", "true");
KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("test
agent", kbase, aconf);
System.out.println("test agent:" + kagent.getName());
kagent.applyChangeSet(ResourceFactory.newUrlResource(fxml.toURI().toURL()));
ksession =
kagent.getKnowledgeBase().newStatefulKnowledgeSession();
Thanks ,
Saurabh
--
View this message in context: http://drools.46999.n3.nabble.com/Facing-problem-in-ResourceChangeScanner...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Re: [rules-users] Complexity Conflict Resolver not working as expected
by FrankVhh
Hi,
To my knowledge, conflict resolvers are only used to determine priority of
rule activations. It does not prevent rules from firing.
You should be able to get the behavior you want by adding activation-groups.
In an activation group, only one rule can fire. See documentation.
Regards,
Frank
vanithap wrote
>
> I have 3 rules
>
> R1 - state=GA, policy type = Home Owner, Rating program = Standard, then
> print a
> R2 - State=GA, Rating Program = Standard, then print b
> R3 - State=GA, then print c
>
> Now I insert the fact with state = GA, policy = HOwner, rating program =
> Standard,
> it matches on all the above 3 rules.
>
> So I wrote my own ComplexityConflictresolver so only one rule should fire
> based on the most matched conditions. But it is firing all the above three
> rules.
>
> This is the piece of code I have in complexity resolver
>
> public int compare(Activation lhs,
> Activation rhs)
> {
> Rule lhsRule = lhs.getRule();
> int numLhsConstraints = getNumConstraintsForRule(lhsRule);
>
> Rule rhsRule = rhs.getRule();
> int numRhsConstraints = getNumConstraintsForRule(rhsRule);
>
> //return numRhsConstraints - numLhsConstraints;
>
> if ( numLhsConstraints > numRhsConstraints ) {
> return 1;
> } else if ( numLhsConstraints < numRhsConstraints ) {
> return -1;
> } else {
> return 0;
> }
> }
>
> private int getNumConstraintsForRule(Rule rule)
> {
> int numConstraints = 0;
>
> Declaration[] declarations = rule.getDeclarations();
> for (Declaration declaration : declarations)
> {
> List constraints = declaration.getPattern().getConstraints();
> if (null != constraints)
> {
> numConstraints += constraints.size();
> }
> }
> return numConstraints;
> }
>
>
>
> This is the piece of code where I hook in the resolver
> RuleBaseConfiguration configuration = new RuleBaseConfiguration();
>
> ConflictResolver[] conflictResolvers = new ConflictResolver[] {
>
> com.test.rulesengine.conflict.ComplexityConflictResolver.getInstance()
> };
> CompositeConflictResolver resolver = new
> CompositeConflictResolver(conflictResolvers);
> configuration.setConflictResolver(resolver);
>
>
> KnowledgeBase knowledgeBase =
> KnowledgeBaseFactory.newKnowledgeBase(configuration);
>
>
> It looks like it is adding all three activations to Agenda and firing each
> one of them.
>
> What am I doing wrong. Any help will be appreciated.
>
> Thanks
>
--
View this message in context: http://drools.46999.n3.nabble.com/Complexity-Conflict-Resolver-not-workin...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Using RDF and RDF Schema to enable dinamic data model
by Jackson Cunha
This message is primarily directed to Davide and Salaboy.
My name is Jackson Cunha. I am brazilian and I am working in a project
using drools expert. In this project, we are trying to abstract the data
model to turn it a dinamic and easily replaced.
For do that, our idea is represent the data model using rdf and rdf schema,
applying rdf instances directly on drools knowledge sessions.
We believe that use of rdf instances will turn the rule writing more
difficult. To address this issue, we are planning buila a DSL using antrl.
Given that, I'd like your opinion about some questions:
- What is your opinion about using rdf instances as facts in knowledge
sessions?
- What do you think the idea of ??using dsl to facilitate rule writing
involving instances of RDF?
- You see any other alternative to make data model dynamic using or not
ontologies?
Thanks in advance.
----------------------------------------------------------------------------------------------------------------
Jackson Cunha Cassimiro (CereB)
Bacharel em Ciencia da Computação - UFPI
MSN: jackson.cereb(a)gmail.com
Telefone Móvel +55 86 9928 1251
Analista de Sistemas - Infoway - http://www.infoway-pi.com.br
Missão Infoway - "Influenciar a Gestão de Sistemas de Saúde através de
e-health"
("A vida é um combate que os fracos abate, aos bravos, aos fortes só pode
exaltar" - Canção do Tamoio, Gonçalves Dias)
----------------------------------------------------------------------------------------------------------------
12 years, 9 months
Unable to use MySQL JNDI datasource with Guvnor
by jvg123
Hi,
[Guvnor 5.4.0.Beta2 on Jboss AS 7.1.1.Final with MySQL]
When I configure Guvnor to use MySQL through a JNDI datasource I get
multiple exceptions:
java.sql.SQLException: You cannot set autocommit during a managed
transaction!
Stack trace attached below.
The exact same datasource works OK without JNDI.
A
http://mail-archives.apache.org/mod_mbox/jackrabbit-users/200812.mbox/%3C...
thread on the JackRabbit mailing list says this is a problem with XA
datasources:
But my datasource is not XA....
Any suggestions would be much appreciated!
Thanks,
Jelle
======================================
2012/03/25 04:00:43,787 ERROR
[org.apache.jackrabbit.core.util.db.ConnectionHelper]
(http--127.10.162.129-8080-3) Failed to execute SQL (stacktrace on DEBUG log
level): java.sql.SQLException: You cannot set autocommit during a managed
transaction!
at
org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:878)
at
org.jboss.jca.adapters.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:715)
at
org.apache.jackrabbit.core.util.db.ConnectionHelper.getConnection(ConnectionHelper.java:395)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.util.db.ConnectionHelper.reallyExec(ConnectionHelper.java:278)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.util.db.ConnectionHelper$1.call(ConnectionHelper.java:267)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.util.db.ConnectionHelper$1.call(ConnectionHelper.java:263)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.util.db.ConnectionHelper$RetryManager.doTry(ConnectionHelper.java:458)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.util.db.ConnectionHelper.exec(ConnectionHelper.java:263)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.util.db.CheckSchemaOperation.run(CheckSchemaOperation.java:89)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.fs.db.DatabaseFileSystem.init(DatabaseFileSystem.java:197)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.config.RepositoryConfigurationParser$6.getFileSystem(RepositoryConfigurationParser.java:1057)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.config.RepositoryConfig.getFileSystem(RepositoryConfig.java:911)
[jackrabbit-core-2.2.8.jar:2.2.8]
at org.apache.jackrabbit.core.RepositoryImpl.(RepositoryImpl.java:285)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.RepositoryImpl.create(RepositoryImpl.java:605)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.TransientRepository$1.getRepository(TransientRepository.java:180)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.TransientRepository.startRepository(TransientRepository.java:280)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.core.TransientRepository.login(TransientRepository.java:376)
[jackrabbit-core-2.2.8.jar:2.2.8]
at
org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
[jackrabbit-jcr-commons-2.2.8.jar:]
at
org.drools.repository.JCRRepositoryConfigurator.login(JCRRepositoryConfigurator.java:95)
[guvnor-repository-connector-jcr-5.4.0.Beta2.jar:5.4.0.Beta2]
at
org.drools.repository.RulesRepositoryConfigurator.login(RulesRepositoryConfigurator.java:85)
[guvnor-repository-5.4.0.Beta2.jar:5.4.0.Beta2]
at
org.drools.guvnor.server.repository.RepositoryStartupService.newSession(RepositoryStartupService.java:118)
[guvnor-webapp-core-5.4.0.Beta2.jar:5.4.0.Beta2]
at
org.drools.guvnor.server.repository.RepositoryStartupService.create(RepositoryStartupService.java:69)
[guvnor-webapp-core-5.4.0.Beta2.jar:5.4.0.Beta2]
--
View this message in context: http://drools.46999.n3.nabble.com/Unable-to-use-MySQL-JNDI-datasource-wit...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Resuable Sub Process From Eclipse to Guvnor
by Amin Mohammed-Coleman
Hi
I tried pushing a bpmn definition from eclipse to Guvnor and it contained a resuable sub process. When I view the definition in Guvnor I don't see the resuable sub process. All I see are connections to but not connected to anything. Has anyone else experienced this?
Thanks
12 years, 9 months
Can I capture the result of an RMI call within a pattern?
by lhorton
5.2.0.Final
consider this simplified example, which has RMI calls to a service to
getLocation()
rule "example"
when
$p : Product( location != remoteService.getLocation("A") )
then
$p.setLocation( remoteService.getLocation("A") );
end
the above rule calls the remote method twice, once in the LHS to compare to
a current value, and again in the RHS to set the value. I would like to
capture the return value of the LHS call, to avoid making the call twice. I
haven't been able to figure out the syntax to do this within the pattern.
Here's one example of what I have tried:
rule "example"
when
$p : Product( location != $loc : remoteService.getLocation("A") )
then
$p.setLocation( $loc );
end
Does anyone know the correct syntax to accomplish this? Or am I trying to
do the impossible?
--
View this message in context: http://drools.46999.n3.nabble.com/Can-I-capture-the-result-of-an-RMI-call...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 9 months
Using planner to create an optimized changeset
by Anton Hughes
Im interested in using Drools Planner to set the salience of a changeset, or
possibly create a new changeset.
So, using the Traveling salesmen problem, but this time the goal is
to reduce
the cost of the trip, we have a collection of rules, like (will write in
english rather than MVEL)
when traveling during holiday period
when traveling to London avoid Heathrow
when traveling more than 8 hours upgrade to business class ( so the
salesperson
is fresh)
when flying into NYC stay at xyz hotel
Would it be possible - or can anyone suggest ways of - generating a
changeset
(using Planner) of rules from another changeset, where the salience is
set, and/or rules are added/removed?
Thanks for you help. And very interested to hear your feedback.
12 years, 9 months