[Flow] Waiting for certain Event based on Event-Data
by Gregor Ryba
Hi,
i've got multiple workitems, i want to process via my workflow
so i'm starting my workflow once with every workitem passed as variable (so they are running simultaneously)
in the workflow i sometimes have to wait for an event to occur - but such an event is only linked to one of the workitems
i added an (Message) Event Node followed by a Join so the process Blocks
class Event{
string ItemId;
}
after receiving the event i could check if the ItemId equals the one of the workitem, but if that's not the case i would have
to go one step back and AGAIN listen for the event.
can i somehow make a loop or anything else, so the process blocks until an Event with the right ItemId occurs?
regards
14 years
Cannot synchronize database state with session
by darren.kay@bt.com
Drools Version: 5.1.0
JBoss Version: 5.1.0 GA (Clustered)
We're using a clustered JBoss setup (with 2 nodes) with Drools and getting an intermittent stale ksession exception - stack trace attached below.
We use 'org.drools.persistence.jpa.JPAKnowledgeService' to persist KnowledgeSession to a MySQL database and use Hibernate to manage the transactions.
In case of a new request, we create a new Drools Knowledge Session and persist it and store the knowledge session id to our database.
StatefulKnowledgeSession session = JPAKnowledgeService.newStatefulKnowledgeSession(knowledgeBase, null, environment);
return session;
For all subsequent requests we load the Knowledge session from the database using the knowledge session id.
StatefulKnowledgeSession session = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId, knowledgeBase, null, environment);
return session;
We receive request from the front-end validate the information and update the knowledge session facts using;
public void insertOrUpdateSessionFacts(StatefulKnowledgeSession session, Object...objects) {
boolean factMatched = false;
for (Object obj: objects) {
//get all session facts
Collection<Object> facts = session.getObjects();
for (Object fact: facts) {
if (fact.getClass().toString().equals(obj.getClass().toString())) {
//update fact in session
session.update(session.getFactHandle(fact), obj);
factMatched = true;
break;
}
}
if (factMatched) {
factMatched = false;
} else {
//fact not found, so insert new fact
session.insert(obj);
}
}
}
After the facts are updated we use find the response variable populated from the Drools flow and pass it back to the front-end;
//get variable scope context
VariableScopeInstance vi = (VariableScopeInstance) processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
return vi.getVariable(variableName);
Any pointers would be much appreciated Stack Trace is below
Darren
-------------------------------------
2010-11-23 04:40:26,838 INFO [STDOUT] (pool-47-thread-1) Hibernate: select workitemin0_.workItemId as workItemId92_0_, workitemin0_.creationDate as creation2_92_0_, workitemin0_.externalVariables as external3_92_0_, workitemin0_.name as name92_0_, workitemin0_.processInstanceId as processI5_92_0_, workitemin0_.state as state92_0_, workitemin0_.OPTLOCK as OPTLOCK92_0_, workitemin0_.workItemByteArray as workItem8_92_0_ from WorkItemInfo workitemin0_ where workitemin0_.workItemId=?
2010-11-23 04:40:26,841 INFO [STDOUT] (pool-47-thread-1) Hibernate: select variables0_.workItemId as workItemId1_, variables0_.id as id1_, variables0_.name as formula1_1_, variables0_.id as id94_0_, variables0_.name as name94_0_, variables0_.persister as persister94_0_, variables0_.processInstanceId as processI5_94_0_, variables0_.workItemId as workItemId94_0_ from VariableInstanceInfo variables0_ where variables0_.workItemId=?
2010-11-23 04:40:26,857 INFO [STDOUT] (pool-47-thread-1) Hibernate: update ProcessInstanceInfo set externalVariables=?, lastModificationDate=?, lastReadDate=?, processId=?, processInstanceByteArray=?, startDate=?, state=?, OPTLOCK=? where InstanceId=? and OPTLOCK=?
2010-11-23 04:40:26,864 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] (pool-47-thread-1) Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.drools.persistence.processinstance.ProcessInstanceInfo#14]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1792)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2435)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:170)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:261)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:85)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
at $Proxy608.invoke(Unknown Source)
at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
at $Proxy607.processKbdRequest(Unknown Source)
at net.plus.kbd.faults.gateway.actions.DroolsFlowSender.process(DroolsFlowSender.java:84)
at sun.reflect.GeneratedMethodAccessor807.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.soa.esb.listeners.message.ActionProcessorMethodInfo.processMethods(ActionProcessorMethodInfo.java:102)
at org.jboss.soa.esb.listeners.message.OverriddenActionLifecycleProcessor.process(OverriddenActionLifecycleProcessor.java:74)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:649)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:603)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:433)
at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:540)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
2010-11-23 04:40:26,871 WARN [com.arjuna.ats.arjuna.logging.arjLoggerI18N] (pool-47-thread-1) [com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator_2] TwoPhaseCoordinator.beforeCompletion - failed for com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple@c9c803
javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.drools.persistence.processinstance.ProcessInstanceInfo#14]
at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:630)
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:588)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:513)
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:101)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:269)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:89)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1423)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:137)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:170)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:87)
at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:261)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.tx.NullInterceptor.invoke(NullInterceptor.java:42)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptorv2.invoke(Ejb3AuthenticationInterceptorv2.java:186)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:41)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.BlockContainerShutdownInterceptor.invoke(BlockContainerShutdownInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:421)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invokeLocal(IsLocalInterceptor.java:85)
at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
at $Proxy608.invoke(Unknown Source)
at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
at $Proxy607.processKbdRequest(Unknown Source)
at net.plus.kbd.faults.gateway.actions.DroolsFlowSender.process(DroolsFlowSender.java:84)
at sun.reflect.GeneratedMethodAccessor807.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.soa.esb.listeners.message.ActionProcessorMethodInfo.processMethods(ActionProcessorMethodInfo.java:102)
at org.jboss.soa.esb.listeners.message.OverriddenActionLifecycleProcessor.process(OverriddenActionLifecycleProcessor.java:74)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:649)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:603)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:433)
at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:540)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.drools.persistence.processinstance.ProcessInstanceInfo#14]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1792)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2435)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:504)
... 45 more
_______________________________________________
rules-dev mailing list
rules-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev
14 years
Simple Drools Planner Example with NQueens
by morge
Hi all,
I am currently looking at Drools planner. I try to solve a simple 4 queens
problem with the following
code:
XmlSolverConfigurer configurer = new XmlSolverConfigurer();
configurer.configure("/org/drools/planner/myexamples/nqueens/app/nqueensSolverConfig.xml");
Solver solver = configurer.buildSolver();
NQueensGenerator generator=new NQueensGenerator();
Solution startingSolution = generator.createNQueens(4);
solver.setStartingSolution(startingSolution);
solver.solve();
Solution bestSolution = solver.getBestSolution();
System.out.println((NQueens) bestSolution);
The config file is the usual one:
<?xml version="1.0" encoding="UTF-8"?>
<localSearchSolver>
<environmentMode>DEBUG</environmentMode>
<scoreDrl>/org/drools/planner/examples/nqueens/solver/nQueensScoreRules.drl</scoreDrl>
<scoreDefinition>
<scoreDefinitionType>SIMPLE</scoreDefinitionType>
</scoreDefinition>
<!-- Real world problems require to use of
<startingSolutionInitializerClass>. -->
<termination>
<terminationCompositionStyle>OR</terminationCompositionStyle>
<maximumStepCount>100</maximumStepCount>
<scoreAttained>0</scoreAttained>
</termination>
<selector>
<moveFactoryClass>org.drools.planner.examples.nqueens.solver.move.factory.NQueensMoveFactory</moveFactoryClass>
</selector>
<acceptor>
<completeSolutionTabuSize>1000</completeSolutionTabuSize>
</acceptor>
<forager>
<pickEarlyType>NEVER</pickEarlyType>
<!-- Real world problems require to use of
<minimalAcceptedSelection> -->
</forager>
</localSearchSolver>
I do not understand why but it does not work:
2010-11-17 11:15:13,791 [main] INFO Solving with random seed (0).
2010-11-17 11:15:13,793 [main] INFO Initialization time spend (4) for score
(0). Updating best solution and best score.
Exception in thread "main" java.lang.ClassCastException:
org.drools.planner.myexamples.nqueens.domain.NQueens
at
org.drools.planner.examples.nqueens.solver.move.factory.NQueensMoveFactory.createCachedMoveList(NQueensMoveFactory.java:35)
at
org.drools.planner.core.move.factory.CachedMoveFactory.solvingStarted(CachedMoveFactory.java:39)
at
org.drools.planner.core.localsearch.decider.selector.MoveFactorySelector.solvingStarted(MoveFactorySelector.java:58)
at
org.drools.planner.core.localsearch.decider.DefaultDecider.solvingStarted(DefaultDecider.java:91)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solvingStarted(DefaultLocalSearchSolver.java:188)
at
org.drools.planner.core.localsearch.DefaultLocalSearchSolver.solveImplementation(DefaultLocalSearchSolver.java:125)
at org.drools.planner.core.AbstractSolver.solve(AbstractSolver.java:57)
at org.drools.planner.myexamples.nqueens.app.Main.main(Main.java:32)
Any idea ?
Thanks in advance,
MM.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Simple-Drools-Planner...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years
Doubt In Flow (HumanTask Persisting).
by Bennet Joseph
Hi All,
I am new to Drools, i have flow, (Start -> HumanTask_1 -> HumanTask_2 ->
Actions -> End)
when the flow starts it will goto Humantask_1,
I need to have workitemhandler for that particular human task(HumanTask_1) ,
how to achieve this.
then, i need to persist the state in DB(oracle), where to do this (i don't
have any idea regarding this).
in Drools Flow document they have given table names (ProcessInstanceLog and
NodeInstanceLog).
what type of column this table have.
when resuming, i need to start from the place where we persisted.
how to add actor and group to the humantask.
how to get response from the humantask, so that flow continues to next node.
when it goes from first human task to the second, is it possible to have
different workitemhandler for that.
and similar things of first humantask.
and i am trying all this things in command lime program, am i doing right,
if not please correct me.
Please help me.
thanks in advance.
Jose
14 years
Urgent..Dynamic nature of rules
by nkumar
Hi,
Is there any way to get the rules from external source rather than loading
this from .drl file every time? because of changing behavior of the rules,
rule file has to be changed if a user introduces a new rule in the system.
Please help me out how can we solve this. i am new to drools and even i
don't know how to write rules properly. Can we store this in a database or
can we save rules somewhere so that next time rather than loading this from
direct rule file, we load this from that data source. User of this
application is non technical and i also need to make an interface to get the
rules in plane English which will convert those into rules accordingly.
Guvnor is not much user friendly. Can anyone please help me out. My deadline
is near.
this is the structure of the rule which i need to make after loading the
data.
when
b:Feature(featureClass.name=="FrontSuspension")
c:Feature(featureClass.name=="FrontAxle")
eval(b.attributes.Capacity>=c.attributes.Capacity)
then
AvailabilityRuleState s = new
AvailabilityRuleState();
s.setValue("A");//Available
s.setReason("");
s.setReference("FA-FS:1");
resultState.add(s);
end
Please help me out. i will really appreciate your help.
Thanks
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Urgent-Dynamic-nature...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years
Single Session versus Multiple Sessions
by Brian Wallis
I'm (very) new to Drools and am trying to determine the best way to use it for our scenario.
I have a domain model that has millions of object instances representing Documents, People and Incidents.
- Incidents are associated with People (1-100+ per person)
- Documents are associated with Incidents (1-50+ per incident)
- Documents are also associated directly with People (1-100+)
- Typical number of documents directly or indirectly associated with
a person is 20-40.
- An incident has a start and end date
- The documents associated with the incident will be created
approximately within the time bounds of the incident
I need to have a workflow for which there will be 1000's of instances that wait for certain documents to be associated with an Incident (or Person) and then continues with an interaction with a user before terminating. It may have to exist for days or weeks.
The simple solution is to have a single session that contains all the documents, incidents and people and to which new documents, incidents and people are added as they arrive at the system. Then I can have a workflow that runs with rules over those facts that will wait until all the necessary documents are available and continue on with the human interaction part.
Of course this won't work. There are too many facts and most of them are not relevant to any particular workflow instance anyway.
So, I'm thinking of doing this with a session per workflow instance where the session is populated with the relevant documents on startup and has any new relevant documents are added when they arrive (using a jms event pipeline).
I can easily filter the event stream to just insert new facts into the session's working memory for documents that are associated with the person and I can pre-populate the session's working memory with a selection of existing documents before starting the workflow. A typical number of documents required for a workflow instance is in the order of 6-50.
So I would create a knowledgebase preloaded with the workflow and rules and create a new session each time I need to run the workflow. At any one time I could have 1000's of sessions. I delete sessions (and reclaim any associated resources) when the workflow completes so I don't need to clean up individual facts. The sessions would need to be stateful and persistent (to a database).
Does this make sense or is there a better way to approach this? Will Drools scale OK when used like this?
thanks,
Brian Wallis
InfoMedix | Architect
p: 3 8615 4553 | f: 3 8615 4501
e: brian.wallis(a)infomedix.com.au
Level 5, 451 Little Bourke Street, Melbourne VIC 3000
14 years
Are implicit ANDs allowed in "not" blocks?
by Nathan Bell
This rule:
rule "Not"
when
not(
RuleTime()
Patient()
)
then
System.out.println("not");
end
produces the following errors when compiled:
[ERR 102] Line 43:5 mismatched input 'Patient' expecting ')' in rule
"Not"
[ERR 102] Line 44:5 mismatched input ')' expecting 'then' in rule "Not"
But if I change it to use explicit ANDs instead of implicit ANDs it
compiles and runs.
rule "NotBlock"
when
not(
RuleTime()
and
Patient()
)
then
System.out.println("notBlock");
end
Is it invalid syntax to use implicit ANDs in a not block? If so, why?
Thank You,
Nathan Bell
14 years
Deadlock using BatchExecutionCommand and Rule that uses the duration attribute
by MacDonald, Bob
Has anyone run into this issue? I've found a couple other references to
deadlocks but nothing that seems to match exactly what I'm seeing. I'm
running with drools 5.1.1 and using the BatchExecutionCommand interface
to feed a set of commands into my StatefulKnowledgeSession. I also have
a simple rule that uses the duration attribute to clean up old facts.
The problem is that the thread that executes the rule associated with
the duration attribute acquires the lock associated with the
DefaultAgenda class object and subsequently tries to acquire the locks
managed by the AbstractWorkingMemory. However, my main thread that uses
the BatchExecutionCommand interface could run while the other thread is
running and this thread first acquires the AbstractWorkingMemory locks
and later tries to acquire the DefaultAgenda class object lock resulting
in the deadlock.
Here's is the stack trace for the thread that runs when duration
expires:
Unsafe.park(boolean, long) line: not available [native method]
LockSupport.park(Object) line: 158
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).parkAndCheckInterr
upt() line: 747
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquireQueued(Abst
ractQueuedSynchronizer$Node, int) line: 778
ReentrantLock$NonfairSync(AbstractQueuedSynchronizer).acquire(int) line:
1114
ReentrantLock$NonfairSync.lock() line: 186
ReentrantLock.lock() line: 262
ReteooStatefulSession(AbstractWorkingMemory).retract(FactHandle,
boolean, boolean, Rule, Activation) line: 1256
DefaultKnowledgeHelper.retract(FactHandle) line: 201
DefaultKnowledgeHelper.retract(Object) line: 214
Rule_Automatically_Remove_Old_Events_0.defaultConsequence(KnowledgeHelpe
r, Event, FactHandle) line: 10
Rule_Automatically_Remove_Old_Events_0DefaultConsequenceInvoker.evaluate
(KnowledgeHelper, WorkingMemory) line: 29
DefaultAgenda.fireActivation(Activation) line: 917
Scheduler$ActivationTimerJob.execute(JobContext) line: 73
JDKTimerService$JDKCallableJob.call() line: 147
JDKTimerService$JDKCallableJob.call() line: 125
FutureTask$Sync.innerRun() line: 303
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>(FutureTask<V>).run()
line: 138
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.access$301(ScheduledT
hreadPoolExecutor$ScheduledFutureTask) line: 98
ScheduledThreadPoolExecutor$ScheduledFutureTask<V>.run() line: 207
ThreadPoolExecutor$Worker.runTask(Runnable) line: 886
ThreadPoolExecutor$Worker.run() line: 908
Thread.run() line: 619
And here's the stack trace of the thread using the BatchExecutionCommand
interface:
DefaultAgenda.fireActivation(Activation) line: 889
DefaultAgenda.fireNextItem(AgendaFilter) line: 856
DefaultAgenda.fireAllRules(AgendaFilter, int) line: 1071
ReteooStatefulSession(AbstractWorkingMemory).fireAllRules(AgendaFilter,
int) line: 785
ReteooStatefulSession(AbstractWorkingMemory).fireAllRules() line: 751
StatefulKnowledgeSessionImpl.fireAllRules() line: 218
FireAllRulesCommand.execute(Context) line: 99
FireAllRulesCommand.execute(Context) line: 33
BatchExecutionCommandImpl.execute(Context) line: 159
BatchExecutionCommandImpl.execute(Context) line: 81
StatefulKnowledgeSessionImpl.execute(Context, Command<T>) line: 887
StatefulKnowledgeSessionImpl.execute(Command<T>) line: 862
Rules$RuleRunnerThread.run() line: 554
The rule with the duration attribute is very simple and included below:
rule "Automatically Remove Old Events"
agenda-group "SYSTEM"
// 1 hour (specified in milliseconds)
duration 3600000
when
$event : Event(eventId : id)
not SituationEvent(correlator == eventId)
then
retract($event);
end
CONFIDENTIALITY NOTICE: The information contained in this e-mail and its
attachments are privileged and confidential and may contain proprietary,
copyrighted or other legally protected information which is intended
solely for the use of the addressee(s). If you are not the intended
recipient, you are hereby notified that any disclosure, use, copying or
distribution of this communication is strictly prohibited. Please
notify the sender immediately and permanently delete this e-mail from
your computer.
14 years