Hold the Beans!
by Donald Winston
I'm reviewing JBoss Rules (Drools) for an application I'm starting to build. It appears that the only way to assert facts is to use the insert(Object) method where the object is a bean using the proper naming conventions for it's properties. There also appears to be a way to use arbitrary objects using globals but do these end up in the fact base? It's disturbing to me that I have to create a bunch of classes whose sole purpose in life is to support the rule base. This is similar to using java server pages and having to create a bunch of classes just to support each page. That's why I don't use java server pages and use xsl transformations instead. I want to use my xml jdom document to represent my data and not have to create a bunch of beans. I can't seem to find anything in the api where I can assert facts without creating my own custom classes. There's no standard Fact class?
I've been also experimenting with Jess and it provides an easy way for me to do this. I just iterate through my jdom document and create Fact objects and assert them. I can then execute the rules and then iterate through the updated fact base using engine.listFacts() and update my jdom document. It couldn't be easier or more natural. Is there an analogous way to do this in Drools?
Thank you very much.
14 years, 2 months
Throwing exceptions from rules.
by tom
Hi,
I have a rule, which in "then section" has:
throw new java.lang.Exception("I cant get this message!");
I throw this exception, and I can get it using catch
(org.drools.runtime.rule.ConsequenceException e) {} in java. But when I try
to get message from exception "e", I get only rule's name:
rule: <rule name>
How can I throw exception with message that I want to have on java side?
I hope it is understandeble... :)
Thanks,
tom.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Throwing-exceptions-f...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Javax.persistence.EntityNotFoundException: No Task with ID 2 was found!
by Eugenio Abello
Hi, I am using drools flow 5.1, and occurr the next problem.
I start OK task 2:
client.start( 2, a_user, responseHandler);
responseHandler.waitTillDone(3000);
But when complete task 2:
client.complete(2, "user", null, responseHandler);
responseHandler.waitTillDone(000);
Hibernate: select task0_.id as id284_3_, task0_.allowedToDelegate as
allowedT2_284_3_, task0_.taskInitiator_id as taskIni22_284_3_,
task0_.priority as priority284_3_, task0_.activationTime as
activati4_284_3_, task0_.actualOwner_id as actualO23_284_3_,
task0_.createdBy_id as createdBy24_284_3_, task0_.createdOn as
createdOn284_3_, task0_.documentAccessType as document6_284_3_,
task0_.documentContentId as document7_284_3_, task0_.documentType as
document8_284_3_, task0_.expirationTime as expirati9_284_3_,
task0_.faultAccessType as faultAc10_284_3_, task0_.faultContentId as
faultCo11_284_3_, task0_.faultName as faultName284_3_, task0_.faultType as
faultType284_3_, task0_.outputAccessType as outputA14_284_3_,
task0_.outputContentId as outputC15_284_3_, task0_.outputType as
outputType284_3_, task0_.parentId as parentId284_3_, task0_.previousStatus
as previou18_284_3_, task0_.skipable as skipable284_3_, task0_.status as
status284_3_, task0_.workItemId as workItemId284_3_, user1_.id as id279_0_,
user2_.id as id279_1_, user3_.id as id279_2_ from Task task0_ left outer
join OrganizationalEntity user1_ on task0_.taskInitiator_id=user1_.id left
outer join OrganizationalEntity user2_ on task0_.actualOwner_id=user2_.id
left outer join OrganizationalEntity user3_ on task0_.createdBy_id=user3_.id
where task0_.id=?
INFO 10-09 13:21:46,436 - SENT: HeapBuffer[pos=0 lim=0 cap=0: empty]
INFO 10-09 13:21:46,437 - SENT: HeapBuffer[pos=0 lim=192 cap=256: 00 00 00
BC AC ED 00 05 73 72 01 00 1F 6F 72 67...]
INFO 10-09 13:21:46,437 - SENT: HeapBuffer[pos=0 lim=0 cap=0: empty]
[2010:09:253 13:09:437:debug] Message receieved on client :
QueryTaskSummaryResponse
[2010:09:253 13:09:437:debug] Arguments : [[]]
[2010:09:253 13:09:444:exception] No Task with ID 2 was found!
javax.persistence.EntityNotFoundException: No Task with ID 2 was found!
at
org.drools.task.service.TaskServiceSession.getEntity(TaskServiceSession.java:669)
at
org.drools.task.service.TaskServiceSession.getTask(TaskServiceSession.java:428)
at
org.drools.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:95)
at
org.drools.task.service.mina.MinaTaskServerHandler.messageReceived(MinaTaskServerHandler.java:41)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:713)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375)
at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:229)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:176)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at
org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
javax.persistence.EntityNotFoundException: No Task with ID 2 was found!
at
org.drools.task.service.TaskServiceSession.getEntity(TaskServiceSession.java:669)
at
org.drools.task.service.TaskServiceSession.getTask(TaskServiceSession.java:428)
at
org.drools.task.service.TaskServerHandler.messageReceived(TaskServerHandler.java:95)
at
org.drools.task.service.mina.MinaTaskServerHandler.messageReceived(MinaTaskServerHandler.java:41)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:713)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375)
at
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:229)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at
org.apache.mina.filter.logging.LoggingFilter.messageReceived(LoggingFilter.java:176)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)
at
org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
at
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61)
at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
14 years, 2 months
Memory management manual or automatic?
by marton.bokor
Hi,
If I have many processes (one starts every minute or so) and I pass
parameters as a map in startProcess and then I am inserting facts into the
working memory. These are local variables (both parameters and facts) in my
code which will eventually come out of scope when leaving their block and
will be garbage collected. I'm using one session for all process instances.
So my question is: when this happens, will the engine recognize this and
free the memory inside the flow or I need to perform manual cleanup like
retracting the fact etc. AFAIK a fact is just a pointer, but will it be
removed from the map by the engine? If so when?
Thanks,
Marton
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Memory-management-man...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Re: [rules-users] Loading facts and memory size limits
by Greg Barton
Do you have rules which relate two arbitrary customers together? If the answer is no (and even a limited yes) then the problem can process customers in parallel. That means you can break the processing down into smaller chunks and you don't need all customers in memory at once.
GreG
On Sep 9, 2010, at 3:27, bellios <carfid(a)gmail.com> wrote:
In my application I would to model the Customers-Sales domain and I thought
that drools could help me to express a set of rules to capture (or execute
on-demand) some "special" customers (e.g. take the customers which not
have/have bought some products of category X in the last 6 months).
To do this i'm loading the last 6 months sales into WM, afterwards on demand
i execute the rules. This process fails due the memory requirements. I
thought that Drools would use an hibernate/JPA/ or an incremental
mechanisms to load and process the facts.
@Swindells, Thomas: Do you think that it's the right approach?
@Michael Anstis-2: I will try to study in deep the event
processing\CEP\streaming methods.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Loading-facts-and-mem...
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
14 years, 2 months
Loading facts and memory size limits
by bellios
Hi all,
i have read the Documentation and the Drools book. I am developping an
application but i don't understand in my case how i can loading a
1,000,000,000 facts (approx).
At present I load all facts into a StatefulKnowledgeSession with a for-
cycle and I insert them into ksession ("ksession.insert(customer);")
The problem is the out of memory exception due the high memory
requirements of facts.
How i can resolve it? There is another approach to
facts loading into session? Can i integrate the loading with JPA/Hibernate
frameworks?
Thanks in advance for any suggestion,
David
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Loading-facts-and-mem...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months
Firing Specific rules using KBase and StatefulKnowledgeSession
by Vignesh
Hi,
We are not able to fire specific rules using KBase and
StatefulKnowledgeSession,
//Code snippet
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.fireAllRules(new RuleNameEndsWithAgendaFilter("test"));
If we use the method directly we are getting the below compile time error,
The method fireAllRules(int) in the type StatefulRuleSession is not
applicable for the arguments (RuleNameEndsWithAgendaFilter)
and when we cast it and used the same by
ksession.fireAllRules((AgendaFilter) new
RuleNameEndsWithAgendaFilter("test")); but getting the below exception,
java.lang.ClassCastException: org.drools.base.RuleNameEndsWithAgendaFilter
Same thing we are able to achieve using RuleBase and WorkingMemory as below,
RuleBase ruleBase = agent.getRuleBase();
WorkingMemory wrkMemory = ruleBase.newStatefulSession();
int i=wrkMemory.fireAllRules(new RuleNameEndsWithAgendaFilter("read"));
Any pointers on how to use this functionality for firing specific rules
using KBase and StatefulKnowledgeSession, by filtering out rules based on
rule names. Please help in this regard.
Thanks,
Vignesh
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Firing-Specific-rules...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 2 months