How to make this rule more memory efficient?
by Ryan Fitzgerald
Hi,
Can anyone advise me on how to make a drools rule more memory efficient? Here is the problem:
I have a Cell and a ProxyCell object classes.
The ProxyCell represents the Cell when their internal ID's match.
Each Cell and ProxyCell however has a unique name (not same as ID).
A Cell can reference (by name) a ProxyCell (as long as the ProxyCell does not represent that actual Cell - which would effectively be a self-reference and is not allowed).
What I want to do is find out where I have a reference from any instance of Cell - cell1 - to any instance of ProxyCell - proxycell2 - but am missing a reference from cell2 to proxycell1 where proxycell2 is a representation of cell2 and proxycell1 is a representation of cell1.
Here is the rule I have written for it:
rule "Check consistent references"
when
$cell1 : Cell()
$cell2 : Cell()
$proxycell1 : ProxyCell ( id = $cell1.id, $cell2.references contains this.name )
$proxycell2 : ProxyCell ( id = $cell2.id, $cell1.references not contains this.name )
then
//report an error.....
end
I have 10,000 instances of Cell and 10,000 instances of ProxyCell in working memory. For each instance of Cell, it can have references to 60 different ProxyCell instances. Loading the Cell and ProxyCell instances into working memory is not a problem. However, when I try to run this rule above, the memory quickly goes above 1GB and I eventually get an out of memory error.
I was wondering if there is a better way to structure or write this rule so that it doesn't use so much memory.
Thanks,
Ryan.
14 years, 6 months
Rules doubt
by Puneet duggal
@ friends,
i am facing a problem in my business rules and it is :-
when i make single mistake in my business rule rest all rules
stops working ,why is it so ? and how can i detect which exact business
rule is having
error
thanks
Puneet
14 years, 6 months
Drools Flow: Workitems with the same name
by tolitius
Hey Drools Crew,
Business process can be designed to have more the one workitem ( human
task ) with the same name. So two questions here:
1. Confirming: "When registering handlers all of the workitems with
the same name will use the same ( registered to the name ) handler?"
2. What is the way for the client to identify the workitem in this
case? Let's say there is a "truly" parallel definition:
/---> workitem1 ( async send to external
system, waiting for completion )
split ----> workitem2 ( async send to external
system, waiting for completion )
\---> workitem3 ( async send to external
system, waiting for completion )
If workitem1 and workitem3 have the same name, and the response
came back for workitem3, how do the client know to "complete" workitem3 vs.
workitem1?
Workitem IDs are completely workflow / drools-flow related, and
when ( let's say ) approval has returned from an external system, a client
should just tell one of the business workflow services to:
completeApprovalFor( ExternalSystem.SuchAndSuch )
workflow service will have a handler to a workflowInstance
{ businessId, sessionId, processInstanceId, List<Work items in progress>,
etc.. }, so if it is a single workitem the process is waiting for, there is
no problem, but if there are more workitems that make the process to wait +
they may have the same name, it creates a problem.
One solution (for the above specific case) would be to link external
systems with work item ids, so instead of List< Workitems in progress >, it
would be Map< ExternalSystem, Workitem >. But it just looks to complex and
specific...
Anything the framework can help with?
Thank you,
/Anatoly
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Workitems...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
addKnowledgePackages Delay
by malkhafaji
Hello,
I am trying to add knowledge packages to an existing KnowledgeBase. My
largest DRL file has 110 rules. I noticed that it may take up to 5 seconds
just to execute the following statement:
this.knowledgeBase.addKnowledgePackages(packages);
where "packages" is just a list of one knowledge package representing one
drl. The nature of my rules is that I initially load a small set of rules
and then at runtime my rules may load other DRLs. The problem is each DRL
loading command (this.knowledgeBase.addKnowledgePackages(packages)) takes a
few seconds and I have no idea why. Although, all those DRLs are already
compiled (at startup time). It is the line I pasted above that takes the
longest time out of anything else I do.
Any idea why just merely adding a KnowledgePackage list to a KnowledgeBase
can take this much time? Do you guys have any suggestions on how I can
reduce this time? I tried to create another dummy KnowledgeBase and get the
KnowledgePackage from it at runtime and add that to my KnowedgeBase above
(thinking that would reduce the time maybe), but not at all.
Any ideas would be great. The API does not have much info on what that add
method exactly does behind the scenes, and how I can get around the long
delays. This is very frustrating to me, and I am not sure where to look.
Thanks for ANY help at all.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/addKnowledgePackages-...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Flow - handling multiple events of the same kind
by Ed Staub
If the same event-node is triggered twice with different data, the same
variable will be recycled for the different data payloads. How does one
ensure that data is not lost?
My best guess is to follow the event node with a composite node, and copy
the top-level variables into the composite's variable scope in the first
sub-node of the composite. But I'm not sure whether I can guarantee that
the composite will be able to do that before the engine handles the second
event.
Suggestions?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Flow-handling-multipl...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Drools Flow: a few questions
by HMandic
Hi, I have two questions regarding flow and human tasks.
First, how do you populate ActorId field in Human task at runtime?
The thing is that I don't know which users are potential owners of a task
when the process is started. Could I call a method that populates actors in
OnEntryAction of a human task?
And could someone give me an example how to do it, maybe a code snippet?
(Not how to call a method, but how to get its result and put it in ActorId
field.)
And second, if I don't use the OnEntryAction approach, how can I access that
task before any of the potential users are inserted into it?
A code snippet would also be greatly appreciated, something like:
<code>
ksession.getProcessInstance().getTask(someIdentifier).setActorId("user1,user2");
</code>
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-a-few-que...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Rules "if one of element of this array has ... "
by Maxime Terrettaz
Hi,
I have OUL_R21 facts which have a array of OUL_R21_ORDER_OBSERVATION
objects.
OUL_R21_ORDER_OBSERVATION object has a array of OUL_R21_OBSERVATION.
OUL_R21_OBSERVATION object has a array of OUL_R21_OBSERVATION_RESULT.
And OUL_R21_OBSERVATION_RESULT has a OBX child.
I want to add the number one in my global list if one of all OBX has
abnormalFlags.value in ( 'HH', 'LL', 'AA', 'H', 'L', 'A' )
if
(OUL_21.ORDER_OBSERVATIONS[*].OBSERVATIONS[*].OBSERVATION_RESULTS[*].OBX.abnormalFlags.value
in ( 'HH', 'LL', 'AA', 'H', 'L', 'A' )){
list.add(1);
}
Here is the rule in tring to create...
package com.xwave.drools
import com.xwave.hapi.hl7v2.model.v24.message.OUL_R21
import com.xwave.hapi.hl7v2.model.v24.group.OUL_R21_ORDER_OBSERVATION
import com.xwave.hapi.hl7v2.model.v24.group.OUL_R21_OBSERVATION
import com.xwave.hapi.hl7v2.model.v24.group.OUL_R21_OBSERVATION_RESULT
import java.util.ArrayList
import ca.uhn.hl7v2.model.v24.segment.OBX
global java.util.List list
/* Pour le chainage de tableau, il est obligatoire de le faire étape après
étape */
rule "Get All OBX"
dialect "mvel"
when
$labMessage : OUL_R21()
$orderObservation : OUL_R21_ORDER_OBSERVATION() from
$labMessage.ORDER_OBSERVATIONS
$observation : OUL_R21_OBSERVATION() from
$orderObservation.OBSERVATIONS
$observationResult : OUL_R21_OBSERVATION_RESULT() from
$observation.OBSERVATION_RESULTS
$obx : OBX() from $observationResult.OBX
then
insert($obx);
end
rule "Abnormals"
dialect "mvel"
when
$result : ArrayList(size > 0) from collect(OBX(abnormalFlags.value in (
'HH', 'LL', 'AA', 'H', 'L', 'A' )))
then
System.out.println("Abnormal result : " + $result);
list.add(1);
end
Could you please tell me the solution.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-if-one-of-eleme...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months
Rules "if one of element of this array has ... "
by Maxime Terrettaz
Hi,
I have OUL_R21 facts which have a array of OUL_R21_ORDER_OBSERVATION
objects.
OUL_R21_ORDER_OBSERVATION object has a array of OUL_R21_OBSERVATION.
OUL_R21_OBSERVATION object has a array of OUL_R21_OBSERVATION_RESULT.
And OUL_R21_OBSERVATION_RESULT has a OBX child.
I want to add the number one in my global list if one of all OBX has
abnormalFlags.value in ( 'HH', 'LL', 'AA', 'H', 'L', 'A' )
if
(OUL_21.ORDER_OBSERVATIONS[*].OBSERVATIONS[*].OBSERVATION_RESULTS[*].OBX.abnormalFlags.value
in ( 'HH', 'LL', 'AA', 'H', 'L', 'A' )){
list.add(1);
}
Here is the rule in tring to create...
package com.xwave.drools
import com.xwave.hapi.hl7v2.model.v24.message.OUL_R21
import com.xwave.hapi.hl7v2.model.v24.group.OUL_R21_ORDER_OBSERVATION
import com.xwave.hapi.hl7v2.model.v24.group.OUL_R21_OBSERVATION
import com.xwave.hapi.hl7v2.model.v24.group.OUL_R21_OBSERVATION_RESULT
import java.util.ArrayList
import ca.uhn.hl7v2.model.v24.segment.OBX
global java.util.List list
/* Pour le chainage de tableau, il est obligatoire de le faire étape après
étape */
rule "Get All OBX"
dialect "mvel"
when
$labMessage : OUL_R21()
$orderObservation : OUL_R21_ORDER_OBSERVATION() from
$labMessage.ORDER_OBSERVATIONS
$observation : OUL_R21_OBSERVATION() from
$orderObservation.OBSERVATIONS
$observationResult : OUL_R21_OBSERVATION_RESULT() from
$observation.OBSERVATION_RESULTS
$obx : OBX() from $observationResult.OBX
then
insert($obx);
end
rule "Abnormals"
dialect "mvel"
when
$result : ArrayList(size > 0) from collect(OBX(abnormalFlags.value in (
'HH', 'LL', 'AA', 'H', 'L', 'A' )))
then
System.out.println("Abnormal result : " + $result);
list.add(1);
end
Could you please tell me the solution.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-if-one-of-eleme...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 6 months