Re: [rules-users] Salience & activation-group
by Java Bean
Or do the check for both parts in both rules , or use inheritance, but the
easiest way would probably be to just have it return null if the number
isn't valid - at least if you are just doing in comparisons.
How do I use inheritance in Drools ?
------------------------------
*From:* "Swindells, Thomas" <TSwindells(a)nds.com>
*To:* Rules Users List <rules-users(a)lists.jboss.org>
*Sent:* Tuesday, December 6, 2011 11:15 AM
*Subject:* Re: [rules-users] Salience & activation-group
> Thanks for your quick response, but I am still confused.
>
> An activation-group assures that only one rule in the group will fire (an
XOR
> group)
>
> Salience controls the order of evaluation
No salience controls the order of the activations firing.
There is no ordering of evaluating rules because rules aren't evaluated.
Instead the rules clauses are transposed into a RETE graph which evaluates
each clause as the necessary data is available.
If two rules share a clause then they may share a node in the RETE graph.
> The regular expression test has the higher salience and will trigger if
it is a bad
> number ... so why is the other rule even being tested?
The RETE graph is evaluated as deeply as possible in order to produce the
current list of possible activations.
The activations are then sorted by salience and filtered by agenda-group.
The top of the list is taken and fired.
If any other pending activations have the same activation-group those
pending activations are then removed.
(It's a lot more complicated than that as you have things such as lock on
active, no-loop, etc but it hopefully
makes it make a little more sense.
>
> In the mean time I will re-write the underWritingClassAsInt method to deal
> with a bad number ... but this seems wrong to me.
Or do the check for both parts in both rules , or use inheritance, but the
easiest way would probably be to just have it return null if the number
isn't valid - at least if you are just doing in comparisons.
Thomas
**************************************************************************************
This message is confidential and intended only for the addressee. If you
have received this message in error, please immediately notify the
postmaster(a)nds.com and delete it from your system as well as any copies.
The content of e-mails as well as traffic data may be monitored by NDS for
employment and security purposes. To protect the environment please do not
print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
4EX, United Kingdom. A company registered in England and Wales. Registered
no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
13 years
Salience & activation-group
by ronalbury
Expert 5.2.Final
My data comes to me as all strings, but I sometimes need to convert some
fields into integers in order to test their value. I wanted to avoid
conversion errors, so I combined rules into an activation-group and used
salience to control the order. However, at runtime I am getting a number
format error in method underWritingClassAsInt. I don't understand why - can
you explain?
rule "XmLifeParticipant underWritingClass Validation"
activation-group "XmLifeParticipant-underWritingClass"
salience 100
when
$lp : XmLifeParticipant(fieldWasModified("underWritingClass")
&& underWritingClass not matches "^\\d$" )
then
$lp.addError(drools.getRule().getName());
end
rule "XmLifeParticipant underWritingClass Value Check"
activation-group "XmLifeParticipant-underWritingClass"
salience 50
when
$lp : XmLifeParticipant(fieldWasModified("underWritingClass")
&& underWritingClassAsInt not in (1, 2, 4, 6))
then
$lp.addError(drools.getRule().getName());
end
--
View this message in context: http://drools.46999.n3.nabble.com/Salience-activation-group-tp3564649p356...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years
Drools fusion example in 5.3.0
by Salina Fung/UFL - ICIL
^
[Line: 56, Column: 28] : [Rule name='If the drop is between 6% and 8%, buy more shares']
Unable to Analyse Expression percent < -0.06:
[Error: Comparison operation requires compatible types. Found class org.mvel2.util.MethodStub and class java.lang.Double]
[Near : {... percent < -0.06 ....}]
I download Drools 5.3.0 Final and try to
run the Broker example that comes with the package. But I got the
following error, what is wrong?
^
[Line: 56, Column: 28] : [Rule name='If the drop is between 6% and 8%, buy more shares']
Unable to Analyse Expression percent < -0.08:
[Error: Comparison operation requires compatible types. Found class org.mvel2.util.MethodStub and class java.lang.Double]
[Near : {... percent < -0.08 ....}]
^
[Line: 69, Column: 28] : [Rule name='If the drop is on more than 8%, sell shares']
Unable to Analyse Expression percent >= -0.06:
[Error: Comparison operation requires compatible types. Found class org.mvel2.util.MethodStub and class java.lang.Double]
[Near : {... percent >= -0.06 ....}]
^
[Line: 83, Column: 28] : [Rule name='If the drop is between 5% and 6%, do nothing']
Thanks
Salina
13 years
ASMAccessorImpl classloader issue?
by ollem
Hi!
I'm trying to use jackson to deserialize JSON to declared types.
When I do that I get classloading problems when inserting the fact into
knowledgespace.
I have explicitly set the context classloader to
org.drools.rule.JavaDialectRuntimeData$PackageClassLoader during
deserialization.
The problem only occurs when I insert facts at a high rate. I use a http to
send data that will be inserted as facts and when I send only 100 facts I
have no problems, when I step this up to around 500 I get the following
stacktrace. Has anybody seen anything like this? Please help me!
Best Regards // Olle Mårtensson
java.lang.ClassNotFoundException: com.digitalroute.betssonpoc.Registration
at java.lang.ClassLoader.findClass:358
at java.lang.ClassLoader.loadClass:306
at java.lang.ClassLoader.loadClass:247
at ASMAccessorImpl_8562899311323165422700.getValue
at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue:73
at org.mvel2.ast.ASTNode.getReducedValueAccelerated:106
at org.mvel2.MVELRuntime.execute:87
at org.mvel2.compiler.CompiledExpression.getValue:122
at org.mvel2.MVEL.executeExpression:954
at org.drools.base.extractors.MVELClassFieldReader.getValue:100
at
org.drools.base.extractors.BaseObjectClassFieldReader.getLongValue:146
at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle:61
at org.drools.common.AbstractFactHandleFactory.newFactHandle:80
at org.drools.common.AbstractFactHandleFactory.newFactHandle:65
at org.drools.common.NamedEntryPoint.createHandle:720
at org.drools.common.NamedEntryPoint.insert:280
at org.drools.common.AbstractWorkingMemory.insert:886
at org.drools.base.DefaultKnowledgeHelper.insert:180
at org.drools.base.DefaultKnowledgeHelper.insert:174
at
com.digitalroute.betssonpoc.Rule_incoming_registration_event.defaultConsequence:14
at
com.digitalroute.betssonpoc.Rule_incoming_registration_eventDefaultConsequenceInvoker.evaluate
at org.drools.common.DefaultAgenda.fireActivation:1091
at org.drools.common.DefaultAgenda.fireNextItem:1029
at org.drools.common.DefaultAgenda.fireAllRules:1251
at org.drools.common.AbstractWorkingMemory.fireAllRules:708
at org.drools.common.AbstractWorkingMemory.fireAllRules:672
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules:218
..........
..........
--
View this message in context: http://drools.46999.n3.nabble.com/ASMAccessorImpl-classloader-issue-tp356...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years
Drools Ruleflow persistence on MySQL - invalid SQL query generated
by victorC
Hi,
After few days of struggling on Drools Ruleflow persistence setup on MySQL I
finally came to the point when I feel it almost works but I am getting an
MySQL error.
I see the following SQL query in the log /it does not look correct/ which
is followed by the MySQL error message.
select processins0_.InstanceId as col_0_0_ from ProcessInstanceInfo
processins0_, EventTypes eventtypes1_ where
processins0_.InstanceId=eventtypes1_.InstanceId and (? in (.))
WARN [JDBCExceptionReporter] SQL Error: 1064, SQLState: 42000
ERROR [JDBCExceptionReporter] You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near '))' at line 1
I googled for similar symptoms but with no success.
Will be very grateful for any support, hint, etc!
My setup is:
JBoss 4.2.3.GA
Hibernate 3.2.4.sp1
JBoss Seam 2.2.0.GA
Drools 5.1.1
MySQL 5.1.41 / mysql-connector 5.0.7
persistence.xml
...
<persistence-unit name="org.drools.persistence.jpa" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/edento-MySQL-ds-XA</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.WorkItemInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.JPAPersistedVariable</class>
<class>org.drools.persistence.processinstance.variabletypes.SerializablePersistedVariable</class>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
</properties>
</persistence-unit>
...
datasources-ds.xml
…
<xa-datasource>
<jndi-name>MySQL-ds-XA</jndi-name>
<xa-datasource-property
name="URL">jdbc:mysql://localhost:3306/db</xa-datasource-property>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<user-name>root</user-name>
<password></password>
<track-connection-by-tx>true</track-connection-by-tx>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<min-pool-size>1</min-pool-size>
<max-pool-size>10</max-pool-size>
<idle-timeout-minutes>10</idle-timeout-minutes>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</xa-datasource>
...
orm.xml
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
version="1.0">
<named-query name="ProcessInstancesWaitingForEvent">
<query>
select
processInstanceInfo.processInstanceId
from
ProcessInstanceInfo processInstanceInfo
where
:type in (processInstanceInfo.eventTypes)
</query>
</named-query>
</entity-mappings>
The bean java code – just starts the process and then immediately attempts
to load it from the database.
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.drools.persistence.jpa");
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
WorkflowProcessInstance processInstance =
(WorkflowProcessInstance)ksession.startProcess("TestProcess");
//retrieving...
ksession =
JPAKnowledgeService.loadStatefulKnowledgeSession(ksession.getId(), kbase,
null, env);
processInstance =
(WorkflowProcessInstance)ksession.getProcessInstance(processInstance.getId());
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Ruleflow-persistence-on-MySQL-in...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years
duration attribute & other rule language features issue
by Prashant Badhe
Hi,
we were using drools engine 5.0.1 version with rules having 'duration',
'agenda-group' attributes and now we want to upgrade drools engine to 5.1.1
or latest 5.3.0 but we find 'duration' feature not working. What are the
equivalents of those features in 5.1.1 and in 5.3.0?
>From drools-expert document, 'duration' seems as deprecated with 'timer'.
But even 'timer' is not working. Putting 'timer' attribute as:
rule "test timer attribute"
agenda-group "enrichment"
auto-focus true
no-loop
salience 140
timer ( int: 5s )
//duration ( 5000 )
when
......
then
......
end
gives "Error: java.lang.ArrayStoreException" Drools compilation error.
"timer ( 5s )" compiles, but the rule never fires.
We are also planning to use @expires in declare. But facts are not seems to
be expiring.
What am I missing here? What are the equivalent for 'duration' in
5.1.1/5.3.0 and how to use @expires in declare?
Please point us to some sample rules that uses these semantics and are
working.
Thanks in advance,
Prashant B.
13 years
Error in resteasy war deployment.....
by subhransu sekhar
Hi,
first i have integrated my resteasy ws to jbpm workflow project and added all the necessay jars to it.it is succesfully excuted in command prompt and created the wars in repository.
but whenever i am trying to deploy that war file in tomcat(6) it shows the following errors:
java.lang.NoClassDefFoundError: org/drools/rule/CompositeClassLoader
at org.drools.builder.impl.KnowledgeBuilderProviderImpl.newKnowledgeBuil
der(KnowledgeBuilderProviderImpl.java:29)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilder(Knowle
dgeBuilderFactory.java:29)
at com.ocqc.flow.OCQCWorkflowManager.readKnowledgeBase(OCQCWorkflowManag
er.java:59)
at com.ocqc.flow.OCQCWorkflowManager.operate(OCQCWorkflowManager.java:40
)
at com.ocqc.flow.OCQCWorkflowManager.initProcess(OCQCWorkflowManager.jav
a:31)
at com.restfully.shop.services.JobResource.getAvailableReport(JobResourc
e.java:72)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.
java:140)
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.
java:255)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220
)
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209
)
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(Synchronous
Dispatcher.java:519)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispa
tcher.java:496)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispa
tcher.java:119)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.
service(ServletContainerDispatcher.java:208)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.servi
ce(HttpServletDispatcher.java:55)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.servi
ce(HttpServletDispatcher.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ss(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:48
9)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.drools.rule.CompositeClassLoade
r
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1647)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1493)
... 33 more
plaese help .....
Thanks & Regards
subhransu sekhar
13 years