stateless & statefulls sessions
by Vinoth Kumar Somasundaram
Hi All,
It would be of great help if someone shares their knowledge on Stateless
and Stateful session with some examples.
Any document on the topic would be of great help. I have been wandering
around in search of a material.
thanks and regards,
vinoth s
________________________________
16 years, 4 months
TypeDeclaration - POJO or TEMPLATE?
by Stephen Kestle
I'm creating a type hierarchy using TypeDeclarations based on an
ontological model (analagous to an xml schema for the purposes of this
post).
If I declare a drl file to have the following declarations
declare Address
line1 : String
line2 : String
end
declare Person
name : String
age : int
address : Address
end
it will create Java Pojo classes for me. However, I had it all working
using fact templates, except for the address item. Is it possible to
insert fact implementations based on templates, while declaring
TypeDeclarations in the drl? (I now go to look for how to specify the
format = TEMPLATE for the drl)
I say this because I'm looking up values using id strings - e.g. the
exact same way that FactTemplate based Facts does accessing. I don't
want to have to convert all my String ids to reflectively call the set
methods on the created Pojo.
Hopefully this is enough info for you 5.0 developers - I'm still trying
to wrap my head around it all.
Cheers
Stephen
16 years, 4 months
Can someone explain what RulebaseConfiguration.setRemoveIdentities(true) does?
by Brett M. Bergquist
In the manual, there is an example when setting up to use identity
assert behavior:
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setAssertBehaviour( AssertBehaviour.IDENTITY );
conf.setRemoveIdentities( true );
RuleBase ruleBase = RuleBaseFactory.newRuleBase( conf );
I need to use AssertBehavior.EQUALITY in one of my RuleBase and I don't
know if I need to call "conf.setRemoveIdentities" or not. The API
documentation is very sparse on what this method does.
Thanks in advance.
Brett
16 years, 4 months
Deploy a new version to BRMS without the web gui
by Martin Rebenstorff
Hello,
I plan to store my rules in BRMS. My rules will frequently change. In addition the rules are to be created/modified dynamically. But I need the possibility of updating my changed rules dynamically in the BRMS via a JAVA interface. The update process may not triggered via the web gui of the BRMS. Is this possible?
Thanks
Martin
_______________________________________________________________________
EINE FÜR ALLE: die kostenlose WEB.DE-Plattform für Freunde und Deine
Homepage mit eigenem Namen. Jetzt starten! http://unddu.de/?kid=kid@mf2
16 years, 4 months
Rule exception
by Delaunay Gaetan
Hi all,
I've got problem with the following rule
rule 'Satellite mediation'
when
PricingField(name=="srv", eval(strValue.contains("VOIX")))
$field : PricingField( name == "duree")
then
mediationManager.addLine(11,$field.getIntValue());
end
I've got this exception when this rule is use
java.lang.AbstractMethodError:
Mediation.Rule_Satellite_mediation_0ReturnValue0Invoker.evaluate(Ljava/lang/Object;Lorg/drools/spi/Tuple;[Lorg/drools/rule/Declaration;[Lorg/drools/rule/Declaration;Lorg/drools/WorkingMemory;)Z
at
org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:210)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:132)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:317)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:140)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:298)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
at org.drools.reteoo.Rete.assertObject(Rete.java:177)
at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:71)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:659)
What's wrong?
16 years, 4 months
DROOLS with BRMS in J2EE Environment
by psentosa
Hi,
sorry for double posting now, I'm afraid my first post which I added to an
existing thread with similar topic, hasn't been looked at because of the
length of the thread :-) so, please apologize
The following problem:
I have some service implementation in my J2EE-based webapp for
calculating/processing inputs from user (I'll call these
calculating/processing service).
I try to integrate drools to do some checking on user input, before it is
saved into the DB and to generate some reports based on already saved data
respectively. The Rule Engine should just gives some feedback about the
rules being violated.
For the integration purpose, I'd like to implement several additional
services for the rule-checking purpose (I'll call this checking-service),
each of which uses RuleAgent to create RuleBase from BRMS. The reason why I
need several services is because I separate my rules in different packages,
depending on which calculating/processing service to use the checking
service, so I don't think all rules should always be included in the RETE
tree.
1st question here: is this the right strategy to separate the rule-checking
into some parts?
Now, for the checking itself, I use drools StatelessSession instance (The
(checking)service class for this is also a stateless session bean). Every
time calculation/processing service is called from the UI, it calls the
checking service, the checking service will do its parts with the Rule
Engine, gets the result, and pass it back to the calculating/processing
service.
2nd question: could such nested calls of services affect the performance of
the webapp (especially bcs it has to make additional call to BRMS for
creating the RuleAgent)
In the .properties file, I put the following options:
newInstance=true
poll=30
....
So, what I got on the console are the following messages, everytime my
checking service is contacted:
11:32:18,484 ERROR [STDERR] RuleAgent(ruleconfig) INFO (Fri Aug 22 11:32:18
CEST 2008): Applying changes to the rulebase.
11:32:18,484 ERROR [STDERR] RuleAgent(ruleconfig) INFO (Fri Aug 22 11:32:18
CEST 2008): Creating a new rulebase as per settings.
11:32:18,484 ERROR [STDERR] RuleAgent(ruleconfig) INFO (Fri Aug 22 11:32:18
CEST 2008): Adding package called mypackage1
The questions:
- why the ERROR [STDERR]?Is there any problem the RE is trying to show?
- Rules should be updateable, but less regularly (probably several times /
year). I set newInstance=true so that the webapp always gets the most
updated rules, but seeing that everytime calls are made, new rulebase is
created as well, I'm worried that there will be too many ressources in use.
Or am I wrong? Is there any alternative how to do this more efficiently?
- what is actually "poll" for? If I already get a fresh ruleagent for every
call, do I still need this one?
The webapp is still in testing phase, but later it should be used in a kind
of mini-cluster as well. Is BRMS also suitable in cluster-environment? Or is
there any limitation for the purpose?
Many thanks for any idea/critics/suggestions/tips, etc. Really appreciate
any response!
Regards
--
View this message in context: http://www.nabble.com/DROOLS-with-BRMS-in-J2EE-Environment-tp19165098p191...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months
Drools problem in Seam
by Earnest Dyke
Greetings all,
I posted this to the Seam users forum and they recommended I post it here as well.
I am using Seam 2.0.0 and Drools 4.0.7. I am getting the following exception when my rule is compiled on first access.
Rule:
package org.ebsinc.ia.rules
#list any import classes here.
import org.ebsinc.ia.entity.BenefitAnalysis;
import org.ebsinc.ia.entity.RetirementEligibility;
#declare any global variables here
rule "Verify FERS"
when
$ba : BenefitAnalysis(plan == "FERS")
$elig : RetirementEligibility(eligible == false)
then
System.out.println("FERS retirement");
$elig.setReason("ok");
end
components.xml
<drools:rule-base name="securityRules" >
<drools:rule-files>
<value>/security.drl</value>
</drools:rule-files>
</drools:rule-base>
<drools:rule-base name="retirementEligibility">
<drools:rule-files>
<value>/RetirementEligibility.drl</value>
</drools:rule-files>
</drools:rule-base>
<drools:managed-working-memory name="retirementEligibilityWM" scope="event"
auto-create="true" rule-base="#{retirementEligibility}" />
Exception:
2008-08-26
08:40:37,750 ERROR [STDERR] at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:123)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
at org.jboss.seam.Component.newInstance(Component.java:1968)
at org.jboss.seam.Component.getInstance(Component.java:1865)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
at org.jboss.seam.drools.ManagedWorkingMemory.getRuleBaseFromValueBinding(ManagedWorkingMemory.java:78)
at org.jboss.seam.drools.ManagedWorkingMemory.getStatefulSession(ManagedWorkingMemory.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.unwrap(Component.java:2100)
at org.jboss.seam.Component.getInstance(Component.java:1879)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2174)
at org.jboss.seam.Component.getValueToInject(Component.java:2126)
at org.jboss.seam.Component.injectAttributes(Component.java:1590)
at org.jboss.seam.Component.inject(Component.java:1408)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
at org.ebsinc.ia.action.AgentAction_$$_javassist_2.getClientSearchKey2(AgentAction_$$_javassist_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 89 more
Caused by: org.mvel.UnresolveablePropertyException: unable to resolve token: declr.identifier
at org.mvel.ASTNode.getReducedValue(ASTNode.java:324)
at org.mvel.ast.PropertyASTNode.getReducedValue(PropertyASTNode.java:32)
at org.mvel.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:110)
at org.mvel.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:58)
at org.mvel.TemplateInterpreter.execute(TemplateInterpreter.java:403)
16 years, 4 months
Drools problem in Seam
by Earnest Dyke
Greetings all,
I posted this to the Seam users forum and they recommended I post it here as well.
I am using Seam 2.0.0 and Drools 4.0.7. I am getting the following exception when my rule is compiled on first access.
Rule:
package org.ebsinc.ia.rules
#list any import classes here.
import org.ebsinc.ia.entity.BenefitAnalysis;
import org.ebsinc.ia.entity.RetirementEligibility;
#declare any global variables here
rule "Verify FERS"
when
$ba : BenefitAnalysis(plan == "FERS")
$elig : RetirementEligibility(eligible == false)
then
System.out.println("FERS retirement");
$elig.setReason("ok");
end
components.xml
<drools:rule-base name="securityRules" >
<drools:rule-files>
<value>/security.drl</value>
</drools:rule-files>
</drools:rule-base>
<drools:rule-base name="retirementEligibility">
<drools:rule-files>
<value>/RetirementEligibility.drl</value>
</drools:rule-files>
</drools:rule-base>
<drools:managed-working-memory name="retirementEligibilityWM" scope="event"
auto-create="true" rule-base="#{retirementEligibility}" />
Exception:
2008-08-26
08:40:37,750 ERROR [STDERR] at
org.drools.rule.builder.dialect.java.JavaConsequenceBuilder.build(JavaConsequenceBuilder.java:123)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:67)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
at org.jboss.seam.drools.RuleBase.compileRuleBase(RuleBase.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.callCreateMethod(Component.java:1997)
at org.jboss.seam.Component.newInstance(Component.java:1968)
at org.jboss.seam.Component.getInstance(Component.java:1865)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.jboss.seam.core.Expressions$1.getValue(Expressions.java:112)
at org.jboss.seam.drools.ManagedWorkingMemory.getRuleBaseFromValueBinding(ManagedWorkingMemory.java:78)
at org.jboss.seam.drools.ManagedWorkingMemory.getStatefulSession(ManagedWorkingMemory.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
at org.jboss.seam.Component.callComponentMethod(Component.java:2074)
at org.jboss.seam.Component.unwrap(Component.java:2100)
at org.jboss.seam.Component.getInstance(Component.java:1879)
at org.jboss.seam.Component.getInstance(Component.java:1832)
at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2174)
at org.jboss.seam.Component.getValueToInject(Component.java:2126)
at org.jboss.seam.Component.injectAttributes(Component.java:1590)
at org.jboss.seam.Component.inject(Component.java:1408)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:155)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:91)
at org.ebsinc.ia.action.AgentAction_$$_javassist_2.getClientSearchKey2(AgentAction_$$_javassist_2.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 89 more
Caused by: org.mvel.UnresolveablePropertyException: unable to resolve token: declr.identifier
at org.mvel.ASTNode.getReducedValue(ASTNode.java:324)
at org.mvel.ast.PropertyASTNode.getReducedValue(PropertyASTNode.java:32)
at org.mvel.MVELInterpretedRuntime.parseAndExecuteInterpreted(MVELInterpretedRuntime.java:110)
at org.mvel.MVELInterpretedRuntime.parse(MVELInterpretedRuntime.java:58)
at org.mvel.TemplateInterpreter.execute(TemplateInterpreter.java:403)
16 years, 4 months
Re: [rules-users] how do RuleBase.lock()/unlock() functions work?
by Marina
Thanks, Mark
Actually, the lock you are describing is a low-level lock on the single add/remove operations. I was more interested in locking a set of operations together.
I guess the only way to do it is to use a normal Java lock outside of the rule engine.
Thanks,
Marina
----- Original Message ----
From: Mark Proctor <mproctor(a)codehaus.org>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Tuesday, August 26, 2008 8:36:29 AM
Subject: Re: [rules-users] how do RuleBase.lock()/unlock() functions work?
you should not need to call .lock() to add or remove packages, the lock
is applied automatically when you cann add/remove on the rulebase.
Likewise ignrore additions/removeas since lock, it's really not
relevant to users.
The Lock is a JDK Lock object, so see that for understanding on how a
lock work.s
Mark
Marina wrote:
> Sorry to bring it up again - just was wondering if anybody knows the answer to my questions below, or maybe it is already somewhere in the documentation?
>
> Thanks!
> Marina
>
>
>
> ----- Original Message ----
> From: Marina <ppine7(a)yahoo.com>
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Sent: Friday, August 22, 2008 3:42:01 PM
> Subject: [rules-users] how do RuleBase.lock()/unlock() functions work?
>
> Hello!
>
> I am researching how to do thread safe update of packages/rules in a rulebase. I noticed that there are lock() and unlock() methods on the RuleBase object, but could not find much documentation on how they could be used.
> I am trying to implement the following scenario and was wondering if someone could verify that I am using the lock functionality correctly in this case:
>
> Thread1:
> 1. rulebase.getStatelessSession()
> 1.1 rulebase.lock()
> 1.2 rulebase.removeRule(rule1)
> 1.3 rulebase.removePackage(somePackage)
> 1.4 rulebase.addPackage(someCompiledNewPackage)
> 1.5 rulebase.unlock()
>
> Thread2
> 2. rulebase.getStatelessSession()
>
> Threads 1 and 2 use the same rulebase object.
> Quesion 1: What does it mean having the rulebase be locked in Thread1? Does it mean, that if Thread2 is trying to get the session , say, between steps1.2 and 1.3 of the Thread1 , then it will wait until Thread1 released the lock on the rulebase?
>
> If that's true, that's exactly what I need.
>
> Question 2: I also see methods rulebase.getAdditionsSinceLock() and getRemovalsSinceLock(). Who will see anything when calling these functions - Thread1 after operation 1.5? before 1.5?
> Or Thread2? But, which lock would it mean to Thread2? - it woudl probably not even be aware of any locks being place by other threads??
>
> Thanks!
> Marina
> _______________________________________________
> 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
16 years, 4 months
Re: [rules-users] how do RuleBase.lock()/unlock() functions work?
by Marina
Sorry to bring it up again - just was wondering if anybody knows the answer to my questions below, or maybe it is already somewhere in the documentation?
Thanks!
Marina
----- Original Message ----
From: Marina <ppine7(a)yahoo.com>
To: Rules Users List <rules-users(a)lists.jboss.org>
Sent: Friday, August 22, 2008 3:42:01 PM
Subject: [rules-users] how do RuleBase.lock()/unlock() functions work?
Hello!
I am researching how to do thread safe update of packages/rules in a rulebase. I noticed that there are lock() and unlock() methods on the RuleBase object, but could not find much documentation on how they could be used.
I am trying to implement the following scenario and was wondering if someone could verify that I am using the lock functionality correctly in this case:
Thread1:
1. rulebase.getStatelessSession()
1.1 rulebase.lock()
1.2 rulebase.removeRule(rule1)
1.3 rulebase.removePackage(somePackage)
1.4 rulebase.addPackage(someCompiledNewPackage)
1.5 rulebase.unlock()
Thread2
2. rulebase.getStatelessSession()
Threads 1 and 2 use the same rulebase object.
Quesion 1: What does it mean having the rulebase be locked in Thread1? Does it mean, that if Thread2 is trying to get the session , say, between steps1.2 and 1.3 of the Thread1 , then it will wait until Thread1 released the lock on the rulebase?
If that's true, that's exactly what I need.
Question 2: I also see methods rulebase.getAdditionsSinceLock() and getRemovalsSinceLock(). Who will see anything when calling these functions - Thread1 after operation 1.5? before 1.5?
Or Thread2? But, which lock would it mean to Thread2? - it woudl probably not even be aware of any locks being place by other threads??
Thanks!
Marina
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
16 years, 4 months