Drools Flow with Persistence and long running tasks
by Chrystall, Greg
Hi,
Does anyone have a production project that is using drools persistence and has long running tasks, which have to run concurrently?
If anyone is, how do you create your KnowledgeSession(s) and handle starting multiple ProcessInstances at the same time?
Thanks,
Greg
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
15 years, 6 months
Re: [rules-users] rules-users Digest, Vol 45, Issue 121
by Burak Aydin
KnowledgeBaseImpl also seems to be unsafe because threads get stuck while
trying to open a new StatefulKnowledgeSession
org.drools.impl.KnowledgeBaseImpl.newStatefulKnowledgeSession()
On Thu, Aug 26, 2010 at 3:49 PM, <rules-users-request(a)lists.jboss.org>wrote:
> Send rules-users mailing list submissions to
> rules-users(a)lists.jboss.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.jboss.org/mailman/listinfo/rules-users
> or, via email, send a message with subject or body 'help' to
> rules-users-request(a)lists.jboss.org
>
> You can reach the person managing the list at
> rules-users-owner(a)lists.jboss.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of rules-users digest..."
>
>
> Today's Topics:
>
> 1. CommandFactory.newSetGlobal and scope (Ricardo J. M?ndez)
> 2. Re: Stuck Threads (Esteban Aliverti)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 26 Aug 2010 15:30:47 +0300
> From: Ricardo J. M?ndez <mendezster(a)gmail.com>
> Subject: [rules-users] CommandFactory.newSetGlobal and scope
> To: rules-users(a)lists.jboss.org
> Message-ID:
> <AANLkTimLN6duK+SMeRuv6ZVUtEhk4B+sdYYBxkfXozLu(a)mail.gmail.com<AANLkTimLN6duK%2BSMeRuv6ZVUtEhk4B%2BsdYYBxkfXozLu(a)mail.gmail.com>
> >
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi everyone,
>
> I'm reading through Michael Bali's Drools JBoss Rules book as well as the
> reference guide, and I've got a question of scope about
> StatefulKnowledgeSessions.
>
> I understand that if I call setGlobal on a stateful session, this global
> value will be shared for all simultaneous calls to executeRules across all
> threads. I'm looking into CommandFactory, which has a newSetGlobal
> method. From what I gather, a global set via CommandFactory.newSetGlobal
> and then executed with a call to
> execute(CommandFactory.newBatchExecution(cmds)) would be scoped solely to
> that execution, regardless of it is a StatefulKnowledgeSession and there
> are
> other parallel command executions against the same session.
>
> Can anyone confirm if that is accurate?
>
> Thanks in advance,
>
> --
> Ricardo J. M?ndez
> http://www.arquetipos.co.cr/
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.jboss.org/pipermail/rules-users/attachments/20100826/d694c41...
>
> ------------------------------
>
> Message: 2
> Date: Thu, 26 Aug 2010 09:48:19 -0300
> From: Esteban Aliverti <esteban.aliverti(a)gmail.com>
> Subject: Re: [rules-users] Stuck Threads
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Message-ID:
> <AANLkTi=-nMM4pkKFbxTa_WWRqpPsFi9QbGN8iY_fSsxC(a)mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> StatefulSessions are not thread safe.
>
> El ago 26, 2010 9:23 a.m., "Burak Aydin" <burak.aydin(a)obss.com.tr>
> escribi?:
>
> Hello,
>
> While trying to open stateful session in a 32 core machine and 35 threads,
> all of the threads hangs. Below is the stack trace. ChainedProperties class
> seems to be thread-unsafe??
>
> gridgain-#13%null%" - Thread t@64
>
> java.lang.Thread.State: RUNNABLE
>
> at
> sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:806)
>
> at
> sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:765)
>
> at
> sun.misc.URLClassPath$JarLoader.findResource(URLClassPath.java:735)
>
> at sun.misc.URLClassPath$1.next(URLClassPath.java:196)
>
> at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:206)
>
> at java.net.URLClassLoader$3$1.run(URLClassLoader.java:416)
>
> at java.security.AccessController.doPrivileged(Native Method)
>
> at java.net.URLClassLoader$3.next(URLClassLoader.java:413)
>
> at
> java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:438)
>
> at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
>
> at
> sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
>
> at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
>
> at
> sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
>
> at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
>
> at
> sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
>
> at
>
> org.drools.util.ChainedProperties.loadProperties(ChainedProperties.java:232)
>
> at org.drools.util.ChainedProperties.(ChainedProperties.java:112)
>
> at org.drools.util.ChainedProperties.(ChainedProperties.java:41)
>
> at org.drools.util.ChainedProperties.(ChainedProperties.java:35)
>
> at
> org.drools.SessionConfiguration.init(SessionConfiguration.java:131)
>
> at org.drools.SessionConfiguration.(SessionConfiguration.java:112)
>
> at
>
> org.drools.impl.KnowledgeBaseImpl.newStatefulKnowledgeSession(KnowledgeBaseImpl.java:134)
>
> at texan.qset.service.QsetService.executeQset(QsetService.java:72)
>
> at texan.qset.service.QsetService.executeQset(QsetService.java:34)
>
> at
>
> texan.crop.service.ProductPostingService.processQSet(ProductPostingService.java:600)
>
> at
>
> texan.crop.service.ProductPostingService.processQSets(ProductPostingService.java:582)
>
> at
>
> texan.crop.service.ProductPostingService.createOrUpdateProduct(ProductPostingService.java:562)
>
> at
>
> texan.crop.service.ProductPostingService.postingProcess(ProductPostingService.java:181)
>
> at
>
> texan.crop.service.ProductPostingService.productPostingProcess_aroundBody0(ProductPostingService.java:85)
>
> at
>
> texan.crop.service.ProductPostingService$AjcClosure1.run(ProductPostingService.java:1)
>
> at org.aspectj.runtime.reflect.JoinPointImpl.proceed(Unknown Source)
>
> at
>
> falez.runtime.aop.FalezTransactionalAspect$4.proceed(FalezTransactionalAspect.java:176)
>
> at
>
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
>
> at
>
> falez.runtime.aop.FalezTransactionalAspect.advice(FalezTransactionalAspect.java:215)
>
> at
>
> falez.runtime.aop.TexanTransactionalAspect.ajc$inlineAccessMethod$falez_runtime_aop_TexanTransactionalAspect$falez_runtime_aop_FalezTransactionalAspect$advice(TexanTransactionalAspect.java:1)
>
> at
>
> falez.runtime.aop.TexanTransactionalAspect.around(TexanTransactionalAspect.java:26)
>
> at
>
> texan.crop.service.ProductPostingService.productPostingProcess(ProductPostingService.java:80)
>
> at
>
> texan.crop.batch.grid.ProductPostingBatch.doCifProcess(ProductPostingBatch.java:45)
>
> - locked texan.crop.batch.grid.ProductPostingBatch@@10880
>
> at
>
> texan.crop.batch.grid.ProductPostingBatch.doProcess(ProductPostingBatch.java:37)
>
> at
>
> falez.runtime.batch.AbstractBatchOperation.doProcess(AbstractBatchOperation.java:209)
>
> at
>
> texan.crop.batch.grid.ProductPostingBatch.doProcess_aroundBody0(ProductPostingBatch.java:29)
>
> at
>
> texan.crop.batch.grid.ProductPostingBatch$AjcClosure1.run(ProductPostingBatch.java:1)
>
> at org.aspectj.runtime.reflect.JoinPointImpl.proceed(Unknown Source)
>
> at
>
> falez.runtime.aop.FalezTransactionalAspect$4.proceed(FalezTransactionalAspect.java:176)
>
> at
>
> org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
>
> at
>
> falez.runtime.aop.FalezTransactionalAspect.advice(FalezTransactionalAspect.java:215)
>
> at
>
> falez.runtime.aop.TexanTransactionalAspect.ajc$inlineAccessMethod$falez_runtime_aop_TexanTransactionalAspect$falez_runtime_aop_FalezTransactionalAspect$advice(TexanTransactionalAspect.java:1)
>
> at
>
> falez.runtime.aop.TexanTransactionalAspect.around(TexanTransactionalAspect.java:26)
>
> at
>
> texan.crop.batch.grid.ProductPostingBatch.doProcess(ProductPostingBatch.java:28)
>
> at
>
> falez.runtime.batch.AbstractBatchOperation.process(AbstractBatchOperation.java:76)
>
> at
>
> falez.runtime.batch.BatchProcessingTask$BatchProcessingJob.doExecute(BatchProcessingTask.java:89)
>
> at
>
> falez.runtime.batch.BatchProcessingTask$BatchProcessingJob.execute(BatchProcessingTask.java:76)
>
> at
>
> falez.runtime.batch.BatchProcessingTask$BatchProcessingJob.execute(BatchProcessingTask.java:1)
>
> at
>
> org.gridgain.grid.kernal.processors.job.GridJobWorker.body(GridJobWorker.java:406)
>
> at
> org.gridgain.grid.util.runnable.GridRunnable$1.run(GridRunnable.java:142)
>
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
>
> at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
>
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
>
> at
> org.gridgain.grid.util.runnable.GridRunnable.run(GridRunnable.java:194)
>
> 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)
>
> --
> Burak AYDIN
> Senior Software Engineer
> OBSS
> -------------------------------------
> 9433 @YKB
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.jboss.org/pipermail/rules-users/attachments/20100826/da59450...
>
> ------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> End of rules-users Digest, Vol 45, Issue 121
> ********************************************
>
--
Burak AYDIN
Senior Software Engineer
OBSS
-------------------------------------
9433 @YKB
15 years, 6 months
Stuck Threads
by Burak Aydin
Hello,
While trying to open stateful session in a 32 core machine and 35 threads,
all of the threads hangs. Below is the stack trace. ChainedProperties class
seems to be thread-unsafe??
gridgain-#13%null%" - Thread t@64
java.lang.Thread.State: RUNNABLE
at
sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:806)
at
sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:765)
at
sun.misc.URLClassPath$JarLoader.findResource(URLClassPath.java:735)
at sun.misc.URLClassPath$1.next(URLClassPath.java:196)
at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:206)
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:416)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader$3.next(URLClassLoader.java:413)
at
java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:438)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
at
sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
at
sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:27)
at
sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:36)
at
org.drools.util.ChainedProperties.loadProperties(ChainedProperties.java:232)
at org.drools.util.ChainedProperties.(ChainedProperties.java:112)
at org.drools.util.ChainedProperties.(ChainedProperties.java:41)
at org.drools.util.ChainedProperties.(ChainedProperties.java:35)
at
org.drools.SessionConfiguration.init(SessionConfiguration.java:131)
at org.drools.SessionConfiguration.(SessionConfiguration.java:112)
at
org.drools.impl.KnowledgeBaseImpl.newStatefulKnowledgeSession(KnowledgeBaseImpl.java:134)
at texan.qset.service.QsetService.executeQset(QsetService.java:72)
at texan.qset.service.QsetService.executeQset(QsetService.java:34)
at
texan.crop.service.ProductPostingService.processQSet(ProductPostingService.java:600)
at
texan.crop.service.ProductPostingService.processQSets(ProductPostingService.java:582)
at
texan.crop.service.ProductPostingService.createOrUpdateProduct(ProductPostingService.java:562)
at
texan.crop.service.ProductPostingService.postingProcess(ProductPostingService.java:181)
at
texan.crop.service.ProductPostingService.productPostingProcess_aroundBody0(ProductPostingService.java:85)
at
texan.crop.service.ProductPostingService$AjcClosure1.run(ProductPostingService.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(Unknown Source)
at
falez.runtime.aop.FalezTransactionalAspect$4.proceed(FalezTransactionalAspect.java:176)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at
falez.runtime.aop.FalezTransactionalAspect.advice(FalezTransactionalAspect.java:215)
at
falez.runtime.aop.TexanTransactionalAspect.ajc$inlineAccessMethod$falez_runtime_aop_TexanTransactionalAspect$falez_runtime_aop_FalezTransactionalAspect$advice(TexanTransactionalAspect.java:1)
at
falez.runtime.aop.TexanTransactionalAspect.around(TexanTransactionalAspect.java:26)
at
texan.crop.service.ProductPostingService.productPostingProcess(ProductPostingService.java:80)
at
texan.crop.batch.grid.ProductPostingBatch.doCifProcess(ProductPostingBatch.java:45)
- locked texan.crop.batch.grid.ProductPostingBatch@@10880
at
texan.crop.batch.grid.ProductPostingBatch.doProcess(ProductPostingBatch.java:37)
at
falez.runtime.batch.AbstractBatchOperation.doProcess(AbstractBatchOperation.java:209)
at
texan.crop.batch.grid.ProductPostingBatch.doProcess_aroundBody0(ProductPostingBatch.java:29)
at
texan.crop.batch.grid.ProductPostingBatch$AjcClosure1.run(ProductPostingBatch.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(Unknown Source)
at
falez.runtime.aop.FalezTransactionalAspect$4.proceed(FalezTransactionalAspect.java:176)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at
falez.runtime.aop.FalezTransactionalAspect.advice(FalezTransactionalAspect.java:215)
at
falez.runtime.aop.TexanTransactionalAspect.ajc$inlineAccessMethod$falez_runtime_aop_TexanTransactionalAspect$falez_runtime_aop_FalezTransactionalAspect$advice(TexanTransactionalAspect.java:1)
at
falez.runtime.aop.TexanTransactionalAspect.around(TexanTransactionalAspect.java:26)
at
texan.crop.batch.grid.ProductPostingBatch.doProcess(ProductPostingBatch.java:28)
at
falez.runtime.batch.AbstractBatchOperation.process(AbstractBatchOperation.java:76)
at
falez.runtime.batch.BatchProcessingTask$BatchProcessingJob.doExecute(BatchProcessingTask.java:89)
at
falez.runtime.batch.BatchProcessingTask$BatchProcessingJob.execute(BatchProcessingTask.java:76)
at
falez.runtime.batch.BatchProcessingTask$BatchProcessingJob.execute(BatchProcessingTask.java:1)
at
org.gridgain.grid.kernal.processors.job.GridJobWorker.body(GridJobWorker.java:406)
at
org.gridgain.grid.util.runnable.GridRunnable$1.run(GridRunnable.java:142)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
org.gridgain.grid.util.runnable.GridRunnable.run(GridRunnable.java:194)
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)
--
Burak AYDIN
Senior Software Engineer
OBSS
-------------------------------------
9433 @YKB
15 years, 6 months
CommandFactory.newSetGlobal and scope
by Ricardo J. Méndez
Hi everyone,
I'm reading through Michael Bali's Drools JBoss Rules book as well as the
reference guide, and I've got a question of scope about
StatefulKnowledgeSessions.
I understand that if I call setGlobal on a stateful session, this global
value will be shared for all simultaneous calls to executeRules across all
threads. I'm looking into CommandFactory, which has a newSetGlobal
method. From what I gather, a global set via CommandFactory.newSetGlobal
and then executed with a call to
execute(CommandFactory.newBatchExecution(cmds)) would be scoped solely to
that execution, regardless of it is a StatefulKnowledgeSession and there are
other parallel command executions against the same session.
Can anyone confirm if that is accurate?
Thanks in advance,
--
Ricardo J. Méndez
http://www.arquetipos.co.cr/
15 years, 6 months
Guvnor -- Business Rules and RuleFlow groups
by Andrew Waterman
Hi all,
I'm wondering how business rules in the Guvnor are meant to interface with rule-flow groups. If I use a specific flow, where in the cycle will business rules be located? Should I specify the ruleflow-group in Guvnor's business rules editor? Some insight on how these ideas should interoperate would be really appreciated. :)
best wishes,
Andrew
15 years, 6 months
How do I get node ID from workItem?
by Alan.Gairey@tessella.com
In Drools Flow, in a work item handler, I need to get the node ID (from
the .rf file) for the given WorkItem instance (using JPA state
persistence).
Is there a reliable way to do this? Any help gratefully received.
Thanks,
Alan
15 years, 6 months
Unable to Access Facts in second rule.
by Ritesh
Hi,
I am trying to work on below rules, there are no compilation errors and all
rules getting executed.
Obersation:
1. Able print message in first rule consequence.
2. Unable to print message in second rule consequence.
3. Not getting exception in the last rule. The Test Data i am working on
should generate one exception in the last rule.
It would be really very helpful if anyone can help.
Thanks and Regards,
Ritesh
Below is my DRL File:
import java.util.List;
import java.math.*;
import java.util.*;
import java.text.*;
import org.apache.commons.lang.*;
declare DistinctAT
d_auditT : String
end
declare ActualSum
auditT : String
tranType : String
sumOfThree : BigDecimal
end
rule "insert combined sum"
agenda-group "init"
auto-focus true
no-loop true
salience 10
dialect 'java'
when
GNMVT( movTransactionType == 'OD', $movType : idMovMovementType,
$tradeSta : movTradeStatus,
$fndCstPrc : movFundCostPrice, $movTranType : movTransactionType,
$movAuditT : movAuditTrail )
//not ActualSum(auditT == $movAuditT, tranType == $movTranType)
then
BigDecimal actSum =
resltForMovTyp($movType).multiply(resltForMovTrdSts($tradeSta)).multiply($fndCstPrc);
ActualSum $as = new ActualSum();
$as.setAuditT($movAuditT);
$as.setTranType($movTranType);
$as.setSumOfThree(actSum);
insert($as);
System.out.println("AT :" + $movAuditT + " Actual Sum :" + actSum);
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Second").setFocus();
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Third").setFocus();
end
rule "insert distinct AT"
agenda-group "Second"
auto-focus true
dialect 'java'
when
$a : ActualSum( $AT : auditT )
not DistinctAT( d_auditT == $AT )
then
DistinctAT $disAT = new DistinctAT();
$disAT.setD_auditT($AT);
insert($disAT);
//System.out.println("Distinct Audit Trial :" + $AT + "TotlNet :" +
$lfna_MO.getPtnaFundTotalNetAsset());
//System.out.println("TotlNet :" +
$lfna_MO.getPtnaFundTotalNetAsset());
System.out.println("Done!");
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Third").setFocus();
end
global ExceptionList exceptions
rule "gpMiscellaneous_Operation"
agenda-group "Third"
when
$r_MO : RuleMetaData(ruleName == "gpMiscellaneous_Operation" )
$lfna_MO : GLFNA(ptnaFundTotalNetAsset != 0)
DistinctAT( $dAT: d_auditT )
$total : BigDecimal()
from accumulate( ActualSum( auditT == $dAT, $actSum_Main : sumOfThree ),
sum( $actSum_Main ) )
eval(
chkRuleExpre( $total,$lfna_MO,$r_MO )
)
then
BaseExceptionBuilder builder =
BaseExceptionBuilder.createBaseExceptionBuilder($r_MO);
BaseException e = builder.createException();
exceptions.add(e);
System.out.println("Done Main Rule");
end
function boolean chkRuleExpre(BigDecimal ttl, GLFNA l, RuleMetaData r)
{
double val = Math.abs( 100 * ttl.doubleValue() /
l.getPtnaFundTotalNetAsset().doubleValue() );
if (val > (Double) r.getRuleArg("Miscellaneous_Operation_Low"))
{return true;}
else{return false;}
}
function BigDecimal resltForMovTyp(String str)
{
if (str.equals("E") || str.equals("R"))
{ return BigDecimal.valueOf(-1.0); }
else
{ return BigDecimal.valueOf(1.0); }
}
function BigDecimal resltForMovTrdSts(String str)
{
if (str.equals("XX"))
{ return BigDecimal.valueOf(-1.0); }
else
{ return BigDecimal.valueOf(1.0); }
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Unable-to-Access-Fact...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 6 months