Temporal constraint not causing rule activation when using StatefulKnowledgeSession.update()
by Nathan Bell
To demonstrate the issue I have simplified the following sample rule to
just the components needed to demonstrate the issue. The example rule
I'm posting here uses the "after" operator; I have also tried this same
test with the before operator. In this sample the rule named "AfterRule"
will activate if the facts are initially inserted in a state matching
the pattern. However, if the facts are inserted in a state that does not
match, and then later updated to match the pattern using
StatefulKnowledgeSession.update() the rule will not activate.
Consider the following DRL:
package test.rules;
dialect "java"
import java.util.Date;
import com.p1s.mps.model.RuleTime;
import com.p1s.mps.model.Patient;
declare RuleTime
@role( event )
@timestamp( time )
end
declare Patient
@role( event )
@timestamp( birthDate )
end
rule "AfterRule"
when
$now : RuleTime( )
Patient( this after $now )
then
System.out.println("after");
end
Separately in a unit test the following actions are performed:
1. Insert an instance of RuleTime into the session where time is
set to now.
2. Insert an instance of a patient into the session where the
birthdate is set to (now - 1 day). [This makes the birthdate in the past
so the rule does not activate]
3. Call fireAllRules(). The rule does not activate, as expected.
4. Modify the patient instance to have a birthdate set to (now + 1
day).
5. Invoke update() on knowledge session.
6. Call fireAllRules(). The rules does not activate. It should
activate here.
If I change step 5 to a retract + insert then the rule will activate in
step 6 as expected.
Thank You,
Nathan Bell
15 years, 3 months
Rules trace questions
by Anais Martinez
Hello.
I'm trying to get the rules trace in execution by using
WorkingMemoryFileLogger. I am using the Hello word example, and I call the
WorkingMemoryFileLogger.wirteToDisk() in the RHS of rules. My modified drl
file is:
import com.sample.DroolsTest.Message;
global org.drools.audit.WorkingMemoryFileLogger rulesLogger
declare Output
@role (event)
end
rule "Hello World"
when
m : Message( status == Message.HELLO, myMessage : message )
then
System.out.println( myMessage + ": Hello message" );
m.setMessage( myMessage );
m.setStatus( Message.GOODBYE );
update( m );
end
rule "GoodBye"
when
Message( status == Message.GOODBYE, myMessage : message )
then
System.out.println( myMessage + ": Goodbye message" );
Output o= new Output();
insert(s);
end
rule "log trace"
when
o:Output( )
then
System.out.println("Loggin trace");
rulesLogger.writeToDisk();
end
I have filtered the logger to see only LogEvent.ACTIVATION_CREATED, and I
set the global rulesLogger in Main(). If I insert 2 messages, 2 "event.log"
files and one "test.log" appears. I have several questions (sorry if I say
nonsense):
First. How do I read the trace for each fire of "rule to log trace"? I mean,
the trace for "rule to log trace" is written forward (from event
insertion/updating/removing to "log trace" activation) or backward (from
"log trace" activation to event insertion/updating/removing)?
Second. Each event.log appears in each "log trace" activation because I am
writing the trace in the RHS. Am I right? Can I use that in order to read
the trace for each individual activation of "log trace"?
Third. I only allow LogEvent.ACTIVATION_CREATED, but some ObjectLogEvent
appear in the test.log file, but not in the event.log files. Why?
Thanks in advance.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-trace-questions...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 3 months
[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
15 years, 3 months
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
15 years, 3 months
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.
15 years, 3 months
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
15 years, 3 months
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.
15 years, 3 months
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
15 years, 3 months