Using Enums in when clause
by Zevenbergen, Alex
Hi,
This is my where clause:
when
resultInfo : TennisResultInfo(endGame == true , setNumber ==
5,gameWinner == PARTICIPANTS.HOME.getId() , gameLoseScore == 0)
then
the rule falls over on PARTICIPANTS.HOME.getId()
PARTICIPANTS.HOME.getId() is an enum and returns an integer.
If I replace this line with the value that it would return the rule runs
perfectly.
Do I have to reference this in a certain way because it is an integer?
(Note all imports are present and correct)
Thanks,
Alex
________________________________________________________________________
Privileged, confidential and/or copyright information may be contained in this communication. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended addressee, you may not copy, forward, disclose or otherwise use this e-mail or any part of it in any way whatsoever. To do so is prohibited and may be unlawful. If you have received this email in error
please notify the sender immediately.
Paddy Power PLC may monitor the content of e-mail sent and received for the purpose of ensuring compliance with its policies and procedures.
Paddy Power plc, Airton House, Airton Road, Tallaght, Dublin 24 Registered in Ireland: 16956
________________________________________________________________________
15 years, 4 months
multi-threaded deadlock?
by Charles Binford
All,
Drools 4.0.7.
I have a single rulebase and three threads running stateless sessions
(each thread has it's own session). All appears to work fine until I
try to dynamically update the packages in the rulebase. That scenario
intermittently hangs on an apparent deadlock. The documentation says,
"Packages can be added and removed at any time...", but maybe this
wasn't assuming a multi-threaded context?
The stack trace of my three threads is below.
- Thread 10 is in the middle if fireAllRules
- Thread 12 is trying to add facts to its session
- thread 11 is trying to add a new package to the ruleBase, but seems to
be in some flavor of fireAllRules on the ruleBase even though there is
no session argument in this code path.
Am I breaking some fundamental drools rule for multi-threading? Do I
need to lock out other sessions from activity while updating packages?
Thanks
Charles Binford
"Thread-10"
java.lang.Object.wait(Object.java)
java.lang.Object.wait(Object.java:485)
org.drools.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:106)
org.drools.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:195)
org.drools.common.AbstractWorkingMemory.getFactHandleByIdentity(AbstractWorkingMemory.java:604)
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:98)
com.sun.evtl.pe.customerPolicy.adm.rules.Rule_turn_on_batch_0.consequence(Rule_turn_on_batch_0.java:8)
com.sun.evtl.pe.customerPolicy.adm.rules.Rule_turn_on_batch_0ConsequenceInvoker.evaluate(Rule_turn_on_batch_0ConsequenceInvoker.java:22)
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:554)
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:518)
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:475)
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)
com.sun.evtl.pe.common.PolicyManager.fireRules(PolicyManager.java:353)
com.sun.evtl.pe.customerPolicy.adm.rules.ArchiveMgrThrd.fireRules(ArchiveMgrThrd.java:132)
com.sun.evtl.pe.customerPolicy.adm.rules.ArchiveMgrThrd.runEngine(ArchiveMgrThrd.java:51)
com.sun.evtl.pe.customerPolicy.adm.msg.PolicyListenerThrd.run(PolicyListenerThrd.java:57)
java.lang.Thread.run(Thread.java:619)
"Thread-11"
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)
org.drools.base.FireAllRulesRuleBaseUpdateListener.beforeRuleBaseUnlocked(FireAllRulesRuleBaseUpdateListener.java:29)
org.drools.event.RuleBaseEventSupport.fireBeforeRuleBaseUnlocked(RuleBaseEventSupport.java:168)
org.drools.common.AbstractRuleBase.unlock(AbstractRuleBase.java:361)
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:456)
com.sun.evtl.pe.common.PolicyManager.addPackage(PolicyManager.java:237)
com.sun.evtl.pe.customerPolicy.adm.rules.ArchiveMgr.loadNewUserRules(ArchiveMgr.java:170)
com.sun.evtl.pe.customerPolicy.adm.msg.PolicyListenerThrd.run(PolicyListenerThrd.java:78)
java.lang.Thread.run(Thread.java:619)
"Thread-12"
java.lang.Object.wait(Object.java)
java.lang.Object.wait(Object.java:485)
org.drools.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:106)
org.drools.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:195)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:743)
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:704)
com.sun.evtl.pe.common.PolicyManager.insertSensor(PolicyManager.java:316)
com.sun.evtl.pe.customerPolicy.adm.rules.ArchiveMgrThrd.assertFacts(ArchiveMgrThrd.java:79)
com.sun.evtl.pe.customerPolicy.adm.rules.ArchiveMgrThrd.runEngine(ArchiveMgrThrd.java:50)
com.sun.evtl.pe.customerPolicy.adm.msg.PolicyListenerThrd.run(PolicyListenerThrd.java:57)
java.lang.Thread.run(Thread.java:619)
15 years, 4 months
Re: [rules-users] Type declaration in DSL
by Matt Geis
You just need to create a mapping like..
There is a product type = productType : ProductType()
There is a customer = customer : Party()
and you can write the LHS of the rule like
when
>not PricingResult()
There is a product type
There is a customer
Matt
*********************
hi all,
I have recently started using Drools 5.0 .I have a difficulty in
writing the expressions in DSL file.i have my .dslr file written like
this
when
>not PricingResult()
>productType : ProductType()
>customer : Party()
then
create a PricingResult
set productType
set customer
now, i am able to fire the rule successfully,with the following in
.dslr file with rule language mappings set to
pricingResult.setProductType(productType);
pricingResult.setCustomer(customer);
where productType and customer are set using CommandFactory.insert(....)
but
i want to remove the below 2 lines from .dslr file and expand them in .dsl file
productType : ProductType()
customer : Party()
how do i declare these types in DSL?
15 years, 4 months
advice on fact loading through database using globals
by Rafael Ribeiro
Hi all,
I am about to start a new project here using Drools and in order to
better understand it I am reading the developer's guide book written
by Michal Bali.
During my readings, one thing caught my attention, on page 26 of the
book the author mentions:
"Use the global variable in a rule condition or a consequence. If used
in a condition, they must return a time-constant value while the rule
session is active."
And that's exactly one of the things our application will need to do
since we'll be checking events against facts stored in a database. One
interesting thing is that it turns out that the architecture we had in
mind is exactly what is described on the page 192 of the book,
services that would be registered as globals would be responsible for
accessing database and augmenting the facts on knowledge sessions when
necessary.
But... if we take the restriction mentioned on page 26 into
consideration we would have to open a new session for each event
received (and close it after). I am pretty sure this isnt much smart
not to mention that it kills any chance of using capabilities
introduced by Fusion.
Is there any other approach we could take to achieve this ?
best regards,
Rafael Ribeiro
15 years, 4 months
(no subject)
by Chandana Pingle
chandana.pingle(a)intunity.com.au
15 years, 4 months
Problems with persistence of drools-flow
by Ševčík Martin
I have a simple flow with human task and I want to persist it into database. I'm using MSSQL DB.
My code is like this:
KnowledgeBase kbase = readKnowledgeBase();
// create the entity manager factory and register it in the environment
EntityManagerFactory emf =
Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
BitronixTransactionManager btm = TransactionManagerServices.getTransactionManager();
env.set( EnvironmentName.TRANSACTION_MANAGER, btm);
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());
// start a new process instance
Map<String,Object> data = new HashMap<String,Object>();
data.put("data3", new MyTask(1,"This is taks 1"));
ProcessInstance pi = ksession.startProcess("com.sample.ruleflow",data);
logger.close();
But when i run it, it end up with this error and there is nothing in the database (the tables were created, but there are all empty):
java.lang.NullPointerException
at org.drools.persistence.processinstance.ProcessInstanceInfo.getId(ProcessInstanceInfo.java:70)
at org.drools.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:34)
at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1620)
at org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:46)
at org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:10)
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:229)
at org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:163)
at com.sample.RuleFlowPersistenceTest.main(RuleFlowPersistenceTest.java:74)
java.lang.RuntimeException: Could not rollback transaction
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:258)
at org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:163)
at com.sample.RuleFlowPersistenceTest.main(RuleFlowPersistenceTest.java:74)
Caused by: java.lang.RuntimeException: Could not execute command
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:255)
... 2 more
Caused by: java.lang.NullPointerException
at org.drools.persistence.processinstance.ProcessInstanceInfo.getId(ProcessInstanceInfo.java:70)
at org.drools.persistence.processinstance.JPAProcessInstanceManager.addProcessInstance(JPAProcessInstanceManager.java:34)
at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1620)
at org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:46)
at org.drools.process.command.StartProcessCommand.execute(StartProcessCommand.java:10)
at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:229)
... 2 more
In JPAProcessInstanceManager.java there this method is called:
public void addProcessInstance(ProcessInstance processInstance) {
ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo( processInstance );
EntityManager em = (EntityManager) this.workingMemory.getEnvironment().get( EnvironmentName.ENTITY_MANAGER );
em.persist( processInstanceInfo );
((ProcessInstance) processInstance).setId( processInstanceInfo.getId() );
processInstanceInfo.updateLastReadDate();
internalAddProcessInstance(processInstance);
}
But em.persist does nothing, no connection do DB is called. And then the next line will fail.
Can anybody help me.
Thanks
Martin Sevcik
15 years, 4 months
Using multiple spreadsheet files in drools
by dtrinh4000
Hi,
I am trying to split my current huge decision table in one excel spreadsheet
into multiple excel files. However, I am unable to run my ruleflow correctly
when they are split up.
Although they compile okay when seperated, the only spreadsheet that ever
gets read is the last one that i compile with the drools spreadsheet
compiler, even though they all get added into the package builder after
compiling them into a drl.
I've tried to search everywhere for the solution but i'm coming up empty.
maybe i am not searching w/ the right parameters. How do I split a decision
table into multiple excel spreadsheets or even workbooks and get them to run
as if they were all in one single excel file?
Would a better way of phrasing my question be, how do i combine multiple
spreadsheets into one drl file?
Thanks.
--
View this message in context: http://www.nabble.com/Using-multiple-spreadsheet-files-in-drools-tp248359...
Sent from the drools - user mailing list archive at Nabble.com.
15 years, 4 months
MVEL parsing / keyword conflict
by Simon Thum
Hi all,
I've stumbled on some mvel integration issues in 5.0.1. I'm using drools
to do, among others, spatial reasoning. At insertion time I maintain a
specialized index, which can be queried later using [collect] from. This
works fine in general.
However, as soon as I use the mvel 2 projections a.k.a. 'in' keyword,
hell breaks loose. 'in' is described here:
http://mvel.codehaus.org/MVEL+2.0+Projections+and+Folds
But I only seem to get syntax errors. If it is possible, to somehow
escape keywords or explicitly pipe through the mvel part, please let me
know!
Needless to say, this feature would be great to have since my object
model is mainly fixed and 'is' allows me to compensate that. Worse, I'd
need to assert objects I don't want to assert to work around.
I tried parenthesizing, only to discover that
... from valid_stmt
is fine, but
... from (valid_stmt)
won't work either. Error 101, reason unknown, but it doesn't even make
it through the parser.
I'd really appreciate to be given an idea why what I did went wrong.
Googling around didn't get me too far.
Cheers,
Simon
15 years, 4 months
Templates Documented as Experimental from Community, not from Red Hat
by Ken Archer
The jboss.org documentation describes rule templates as "an experimental feature. In particular, the API is
subject to change". However, the Red Hat documentation does not caveat rule templates as "experimental" in any way. Are templates (which are available in other BRMSs) no longer considered "experimental"? Thanks so much.
Ken Archer
Telogical Systems
15 years, 4 months
Re: [rules-users] Drools Guvnor Remoting API
by Michael Rhoden
Michael Neale would know better on the progress, but we discussed this exact feature back at Javaone a few months ago. My view is the selectors are still experimental, but are very close to being able to use. There have been talks about how to harden it up and do just what you are asking for. I believe there is a REST api for guvnor as well as webdav, but I dont think they talk to the selectors yet, though I could be wrong.
Given this is a feature we want, and I know Michael Neale has agreed its a good idea and needed, what is your interest in Co-developing/Testing something like this with us?
Michael Rhoden
VP - IT Development
Franklin American Mortgage Company
Direct: 615-778-1117
Fax: 615-778-2766
Email: mrhoden(a)franklinamerican.com
----- Original Message -----
From: "Steve Ronderos" <steve.ronderos(a)ni.com>
To: rules-users(a)lists.jboss.org
Sent: Tuesday, August 4, 2009 10:42:33 AM GMT -06:00 US/Canada Central
Subject: [rules-users] Drools Guvnor Remoting API
Hello Again,
I asked a question similar to this awhile back, David Sinclair answered some of my questions, but I'm still looking for a few features.
Here is my use case.
We are deploying Guvnor to an enterprise environment.
We plan on having one Guvnor for our rule authors to create/edit rules in.
We plan on using selectors to control which rules are included into packages that are built for different environments (development, test, production).
We can't have our application that use rules pointing directly at the Guvnor instance.
We want an automated "deployment" process.
Here is what I was thinking.
I would like to be able to invoke a build, using a specified selector, then create a snapshot that follows a specific naming convention (ie with the selector's name in the snapshot name), in sequence. In order to do this, I would like to, from a remote application, tell Guvnor to do a build, then to do a snapshot. So essentially what I'm asking for is a remoting API for Guvnor's features. I've looked through some of the Guvnor code and I believe I see that there is a remote API for the drools-repository that Guvnor sits on, but what I need is specifically Guvnor's features to be made available in a remoting API.
Does anyone know if such a thing exists? If not is it planned? If not, am I even asking for a desirable feature?
Thanks,
Steve Ronderos
_______________________________________________ rules-users mailing list rules-users(a)lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
15 years, 4 months