[Drools Flow] Stop a timer event
by JAMAL Moundir (EXT)
Hello,
I'm using Drools Flow 5, I have N Message events waiting for a signal to be started, I want to launch a Timer in the beginning of my WorkFlow, if one of the event is received, then I want to stop the Timer and execute my workflow, else I want to execute another branch of my workflow.
For example :
1- Start
- Launch the Timer of 30s
- Wait for a Message (external event)
2- Case 1 : External event received before 30s
- Execute SubProcess 1 and stop the Timer
Case 2 : Timer reached 30s
- Execute SubProecss 2 and ignore the external event
How can I stop the Timer when the case 1 is verified ? Can I do such as thing with Drools Flow ?
In my current implementation even when the case 1 is verified, after the 30s the subProcess2 is also executed !
Did someone implement such us thing
Thanks,
Regards
*************************************************************************
This message and any attachments (the "message") are confidential, intended solely for the addressee(s), and may contain legally privileged information.
Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration.
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or
falsified.
************
Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et susceptibles de contenir des informations couvertes
par le secret professionnel.
Ce message est etabli a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite.
Tout message electronique est susceptible d'alteration.
La SOCIETE GENERALE et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie.
*************************************************************************
15 years
Manuel's Analysis of JBRULES-2887 (NPE in AccumulateNode.java:967)
by Wolfgang Laun
Thanks a lot, and I've added your analysis as a comment to JBRULES-2887.
Wolfgang
2011/4/3 Manuel Ortiz <manuel.ortizramos(a)gmail.com>
> Hi Wolfgang:
>
> I write to you concerning JIRA
> https://issues.jboss.org/browse/JBRULES-2887, which the SampleAlarmRules
> scenario which was attached to this discussion was added in.
>
> I've executed several times the SampleAlarmRules scenario and found that
> the problem in that scenario is the existence of a JoinNode (Node 18) which
> feeds two nodes, a JoinNode (Node 20) and an AccumlateNode (Node 25, the one
> in which NPE occurs). I've seen that the child tuples of a join node are
> interconnected via pointers and that those connections must be updated every
> time a parent tuple of the join node is modified, via reAddLeft and
> reAddRight tuple methods. When a JoinNode feeds two or more nodes, the child
> tuples are interconnected in a ordered way that mixes tuples with different
> sinks.
>
> In the SampleAlarmRules scenario, when JoinNode18 is right modified, the
> CompositeLeftTupleSinkAdapter processes several child tuples, but only the
> last one is returned and reAddLeft'ed, hence breaking the child tuple
> relations which it seems necessary to keep rete coherence. After this right
> modify, the next left modify fails because a child tuple related to one node
> of the composite sink is used to check the next operation to do in another
> sink node different from the first one. This leads to a chain of incorrect
> assertions which ends in the AccumulateNode NPE.
>
> I've rewriten my rules in order to JoinNode18 feeds only AccumulateNode25
> thus avoiding the NPE and returning to my user role. However I am not sure
> if any CompositeSink starting at a JoinNode will have this or other problems
> when being left or right modified. I hope this information helps to solve
> this problem.
>
> Best regards,
>
> Manuel Ortiz.
>
>
> 2011/3/31 Wolfgang Laun <wolfgang.laun(a)gmail.com>
>
>>
>>
>> 2011/3/31 Manuel Ortiz <manuel.ortizramos(a)gmail.com>
>>
>>> Hi Wofgang:
>>>
>>> Thank youvery much for your response. I was replaying to Mauricio when
>>> your email has arrived. I hope the test case is useful.
>>>
>>>
>> Thanks. Files are attached to the JIRA and JIRA is now at "critical".
>> -W
>>
>>
>>> Best regards,
>>>
>>> Manuel Ortiz.
>>>
>>>
>>> 2011/3/31 Wolfgang Laun <wolfgang.laun(a)gmail.com>
>>>
>>>> Manuel,
>>>>
>>>> I have reported this (or a very similar) problem
>>>> https://issues.jboss.org/browse/JBRULES-2887 with a small example to
>>>> reproduce.
>>>>
>>>> The stack trace is not identical, so please try to reproduce this with a
>>>> small test case; it is bound to happen with a rule (Test Negativo Alarma
>>>> Acceso Portal Ubicacion UM) that modifies some fact that is used in an
>>>> "accumulate" phrase, (If this pattern is different from the one I gave, I'll
>>>> raise the issue priority to "critical".)
>>>>
>>>> Cheers
>>>> Wolfgang
>>>>
>>>>
>>>> 2011/3/30 Manuel Ortiz <manuel.ortizramos(a)gmail.com>
>>>>
>>>>> Hello all!
>>>>>
>>>>> I am new in Drools but day by day, test by test, I think I get a bit
>>>>> more knowledge of how the rule engine works from user point of view. I've
>>>>> been adding rules to an alarm system, increasing the complexity and
>>>>> functionality in several steps. Unfortunately in the last step I found the
>>>>> following NullPointerException inside the rule engine...
>>>>>
>>>>> java.lang.NullPointerException
>>>>> at
>>>>> org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967)
>>>>> at
>>>>> org.drools.reteoo.AccumulateNode.modifyLeftTuple(AccumulateNode.java:329)
>>>>> at
>>>>> org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:239)
>>>>> at
>>>>> org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:640)
>>>>> at
>>>>> org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:270)
>>>>> at org.drools.reteoo.BetaNode.modifyObject(BetaNode.java:312)
>>>>> at
>>>>> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:460)
>>>>> at
>>>>> org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:428)
>>>>> at org.drools.reteoo.AlphaNode.modifyObject(AlphaNode.java:160)
>>>>> at
>>>>> org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:460)
>>>>> at
>>>>> org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:428)
>>>>> at
>>>>> org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:263)
>>>>> at
>>>>> org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:172)
>>>>> at
>>>>> org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1442)
>>>>> at
>>>>> org.drools.common.AbstractWorkingMemory.update(AbstractWorkingMemory.java:1349)
>>>>> at
>>>>> org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:183)
>>>>> at
>>>>> org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:196)
>>>>> at
>>>>> es.simcasva.alarmas.rules.Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0.defaultConsequence(Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0.java:18)
>>>>> at
>>>>> es.simcasva.alarmas.rules.Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0DefaultConsequenceInvoker.evaluate(Rule_Test_Negativo_Alarma_Acceso_Portal_Ubicacion_UM_0DefaultConsequenceInvoker.java:44)
>>>>> at
>>>>> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
>>>>> at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
>>>>> at
>>>>> org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)
>>>>> at
>>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)
>>>>> at
>>>>> org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)
>>>>> at
>>>>> org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
>>>>>
>>>>> I've been trying to find the problem, and found a strange interaction
>>>>> between three rules that makes the null pointer to appear. The alarm system
>>>>> has many rules now and it is difficult to simplify the scenario, so I just
>>>>> would like to know what is the funcion of AccumulateNode object in order to
>>>>> have an idea of the NullPointerException possible cause.
>>>>>
>>>>> Can anyone help me?
>>>>>
>>>>> Thank you in advance for your time.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Manuel Ortiz.
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> rules-users mailing list
>>>>> rules-users(a)lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users(a)lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>
>>>>
>>>
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
15 years
KnowledgeAgent Issue
by Steven Williams
Hi all,
I am trying to use a Knowledge Agent in 5.1.1 with a change set with a few
different packages and resource types in it, and I am running into a problem
where it is not adding all the packages. Looking at the code I can see that
KnowledegeAgentImpl.createPackageFromResource has the following code when it
loads a resource:
if (kbuilder.getKnowledgePackages().iterator().hasNext()) {
return (KnowledgePackageImp)
kbuilder.getKnowledgePackages().iterator().next();
}
and KnowledgeBuilderImpl.getKnowledgePackages does the following:
Package[] pkgs = pkgBuilder.getPackages();
List<KnowledgePackage> list = new ArrayList<KnowledgePackage>( pkgs.length
);
and PackageBuilder.getPackages does the following:
for ( PackageRegistry pkgRegistry : this.pkgRegistryMap.values() ) {
Package pkg = pkgRegistry.getPackage();
// add package to array
}
pkgRegistryMap is implemented as a HashMap however so the order the packages
are returned in is not guaranteed. I seem to be hitting this problem.
This is a hard one to create a unit test for so I wanted to check that my
analysis is correct before raising a bug. Perhaps using a LinkedHashMap or
similar would fix it?
thanks
Steve
15 years
Rule does not fire after 'Modify/Update' of a fact - Drools 5.1.1 !
by groovenarula
Hello all,
For some reason I have a rule that does not fire after a Modify/Update.
I have 2 facts - Product and Option. The relationship between them is that a
'Product' can have 0 - N 'Option'(s).
Based on that, I added a 'product' field to the 'Option' object. I'm
creating and inserting my facts
using the following code :
Product prod = new Product ("001","002", "A");
prod.setPrice(new BigDecimal("300.00"));
Option opt = new Option ("H1","",prod);
ksession.insert(prod);
ksession.insert(opt);
Now in my .DLR, I have the following rule :
rule "Set Options price"
salience 50
when
$prod : Product ( price != null )
$option : Option ( product == $prod )
then
System.out.println( "Getting Options " + $prod );
end
This gives me the correct output in the console :
Getting Options Product [category=001, grade=A, price=300.00, style=002]
The rule fired successfully.
I start running into problems when I try to update the 'price' field using a
rule, instead of through code.
So for example, if I have the following rule also defined in the same drl
file :
rule "Set price"
salience 500
when
$prod : Product ( category == "001", price == null )
then
$prod.setPrice ( new BigDecimal ( "300.00" ) );
update( $prod );
System.out.println( $prod );
end
And then change my code as follows (remove the setPrice call) :
Product prod = new Product ("001","002", "A");
Option opt = new Option ("H1","",prod);
ksession.insert(prod);
ksession.insert(opt);
I only get the following output :
Product [category=001, grade=A, price=300.00, style=002]
What am I missing here ? I thought the rule 'Set Price' should update the
product fact with
the new price and the rules would get re-evaluated. After the re-evaluation,
the LHS of 'Set Options Price' should now be true and it should have fired.
But it does not.
Am I mis-understanding something about activation here ? If I am, can
someone please help explain what the gap is and how to re-write the rules so
that I can achieve the above objective ?
Any help will be appreciated. I've spend several hours trying different
permutations and combinations and got no where.
Thanks
Gurvinder
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-does-not-fire-af...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years
Map Accessor not allowing using a $parameter, gets field extractor error
by AberAber
Using Drools 5.1.1
Is there anything I can do except to make a method/property in my original
class to do the .get into map for me? According to drools specs this should
work.
This gets the error:
rule "Find Lowest Score"
salience 100
when
$aobject : DataObject($index: extracted.indexString)
$node : Information($classScore : adjustedScores[$index])
then
System.out.println(" Class score " + $classScore);
end
Description Resource Path Location Type
BuildError: Unable to create Field Extractor for 'adjustedScores[$index]'
droolsLocal.drl /src/main/resources line 30 Drools Error
This works:
rule "Find Lowest Score"
salience 100
when
$aobject : DataObject($index: extracted.indexString)
$node : Information($classScore : adjustedScores["ASTRING"])
then
System.out.println(" Class score " + $classScore);
end
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Map-Accessor-not-allo...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years
Speed up inserting of rules into knowledge base
by Piotr Jedrychowski
Hello.
I'm loading a big amount of rules during starting of JBoss (20000
rules). All rules (in string format) are available before JBoss startup
- they are stored into database. Rules are loaded one by one and it
takes about 90 minutes. I want to speed up this process. Is there
something like "bulk load" for inserting rules into knowledge base or
another smart way to fast loading a big amount of rules?
I'm using:
1) Drools 5.1
2) JBoss 4.2.3
My source code looks like this:
String rule = ...
Resource resource = ResourceFactory.newReaderResource(new
StringReader(rule));
KnowledgeBuilder knowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
knowledgeBuilder.add(resource, ResourceType.DRL);
knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
Regards,
Piotr
15 years
Spring + Drools + Console Application
by Anderson Neves
Hi everybody.
I am having a problem to instantiate a console application with Drools and
Sping. With Spring, I am able to instanciate a bean and print its value to
console, but with Spring + Drools I get this error:
Exception in thread "main"
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'kbase': Invocation of init method failed; nested exception is
java.lang.RuntimeException: Unable to parser Reader
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.test.Test.main(Test.java:10)
Caused by: java.lang.RuntimeException: Unable to parser Reader
at org.drools.compiler.DrlParser.getParser(DrlParser.java:313)
at org.drools.compiler.DrlParser.parse(DrlParser.java:141)
at org.drools.compiler.DrlParser.parse(DrlParser.java:147)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:263)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:458)
at
org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:519)
at
org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28)
at
org.drools.container.spring.beans.KnowledgeBaseBeanFactory.afterPropertiesSet(KnowledgeBaseBeanFactory.java:103)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 15 more
Caused by: java.lang.NullPointerException
at java.io.FilterInputStream.close(Unknown Source)
at
sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream.close(Unknown
Source)
at sun.nio.cs.StreamDecoder.implClose(Unknown Source)
at sun.nio.cs.StreamDecoder.close(Unknown Source)
at java.io.InputStreamReader.close(Unknown Source)
at
org.antlr.runtime.ANTLRReaderStream.load(ANTLRReaderStream.java:92)
at
org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:68)
at
org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:52)
at
org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:48)
at
org.antlr.runtime.ANTLRInputStream.<init>(ANTLRInputStream.java:40)
at org.drools.compiler.DrlParser.getParser(DrlParser.java:308)
... 24 more
I use eclipse, and running from the IDE Spring + Drools in a console
application works fine. This problem happens when I generate an executable
jar and try the "java -jar" command.
My main method is below
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("appConfig.xml");
StatefulKnowledgeSession ksession = (StatefulKnowledgeSession)
context.getBean("ksession");
System.out.println(ksession);
}
And my applicationContext.xml is below
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:drools="http://drools.org/schema/drools-spring"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://drools.org/schema/drools-spring
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-containe...
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<drools:kbase id="kbase">
<drools:resources>
<drools:resource source="classpath:knowledgebase-config.xml"
type="CHANGE_SET" />
</drools:resources>
</drools:kbase>
<drools:ksession id="ksession" type="stateful" kbase="kbase" />
</beans>
Any clue of what is cousing the problem? Thank you very much.
Regards,
Anderson
15 years
Import repository in Guvnor
by Sébastien Raickman
Hi guys,
do someone have an example how to call the "org.drools.guvnor.Guvnor/backup"
(RepositoryBackupServlet) servlet for uploading a repository_export.xml?
Thanks in advance!
Seb
15 years
Rule architecture question - avoiding condition duplications
by Hezi Stern
Hi all,
I have a general question regarding best practice or perhaps better put as
right architecture design.
We are using Drools (Expert in particularly) to model and execute the
behavior aspects of our service, which revolves around meeting scheduling
between various users.
My main challenge is how to properly structure the rules so that they
provide the desired flexibility to both modify and control over time.
Following is a small example which illustrates my question:
I need to determine a specific execution time and it is based on many
conditions and in general about 15 scenarios where I create a rule per
scenario. I find that there is a wide set of conditions that are common to
all scenarios.
So for example a rule would look like:
when
a1 == X1
a2 == X2
a3 == X3
a4 == X4
b1 == Y1
Then
Something .
Another rule would be
when
a1 == X1
a2 == X2
a3 == X3
a4 == X4
b2 == Y2
Then
Something else .
As you can see I am duplicating the a' conditions which are the common
conditions and the b' is a new unique condition. It seems to me like a
poorer code maintainability and possibly performance reduction (but I may be
wrong, perhaps this is how rules should be written).
I assume this is a common case in rules so my question is what would be the
best way (architecturally wise) to implement such cases (e.g. insert a new
class that indicates that conditions a' are set and base the rules on the
existence of such a class)
Thanks
Hezi
15 years
subscription
by Qi Zhao
subscription
-------------------------------------------
Qi Zhao
Sent to My MacBook Pro's Mail
15 years