Re: [rules-users] Concurrency problem in PackageClassLoader

2011-09-28 Thread S_Kumar_P
I also was getting this error. I brought out package building logic to execute 
once, and KnowledgeSession related logic to repeat the required number of times.

Seems there required some delay in preparing rules related classes into one 
package during iteration and loading the same. Above step was working fine for 
me.

Pseudo code:

  KnowledgeBuilder kbuilder = 
KnowledgeBuilderFactory.newKnowledgeBuilder();

  // this will parse and compile in one step

  // get the compiled packages (which are serializable)
  Collection pkgs = null;

  // add the packages to a knowledgebase (deploy the knowledge packages).
  KnowledgeBase kbase = null;

  StatefulKnowledgeSession ksession = null;
  // constructor to be called once
public RuleEngine (byte[] rules) {

kbuilder.add(ResourceFactory.newByteArrayResource(rules),ResourceType.DRL);
//  Check the builder for errors
if (kbuilder.hasErrors()) {
  System.out.println(kbuilder.getErrors().toString());
  throw new RuntimeException("Unable to compile drl.");
}
pkgs = kbuilder.getKnowledgePackages();

// add the packages to a knowledgebase (deploy the knowledge 
packages).
kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(pkgs);
  }

// this method will be called required number of times
  public void fire(Object obj) {

ksession = kbase.newStatefulKnowledgeSession();
ksession.addEventListener(new DebugAgendaEventListener());
ksession.addEventListener(new DebugWorkingMemoryEventListener());

// setup the audit logging
//KnowledgeRuntimeLogger logger = 
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/drools.log");

ksession.insert(obj);

ksession.fireAllRules();

//logger.close();

ksession.dispose();
  }


Check this out.


Thanks & Regards
Santhosh Pallerla

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of nicolas
Sent: Thursday, September 29, 2011 8:09 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Concurrency problem in PackageClassLoader

Hi,

We are using a single (Drools 5.1.1) Stateless Sessions for the parallel 
processing of thousands of facts.

>From time to time we experienced the following error :

org.drools.runtime.rule.ConsequenceException: rule: Priorite - Groupe: 
TMK2612G01, P10

  at 
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)
  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)
  at 
acme.srv.ept.service.impl.traitement.MoteurTraitementDemandes.traiterDemande(MoteurTraitementDemandes.java:121)
(...)
Caused by: java.util.ConcurrentModificationException
  at java.util.HashMap$AbstractMapIterator.checkConcurrentMod(Unknown 
Source)
  at java.util.HashMap$AbstractMapIterator.makeNext(Unknown Source)
  at java.util.HashMap$KeyIterator.next(Unknown Source)
  at java.util.HashMap.analyzeMap(Unknown Source)
  at java.util.HashMap.rehash(Unknown Source)
  at java.util.HashMap.rehash(Unknown Source)
  at java.util.HashMap.putImpl(Unknown Source)
  at java.util.HashMap.put(Unknown Source)
  at 
org.drools.rule.JavaDialectRuntimeData$PackageClassLoader.loadClass(JavaDialectRuntimeData.java:503)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
  at  
acme.srv.ept.regle.Rule_Priorite___Groupe__TMK2612G01__P10_0DefaultConsequenceInvoker.evaluate(Rule_Priorite___Groupe__TMK2612G01__P10_0DefaultConsequenceInvoker.java:29)
  at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
  ... 49 more

We get the same error when we used a pool of Stateless Sessions (serial access) 
based on the same KnowledgeBase for the processing.


Thanks,
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor Repository Report

2011-09-28 Thread jliu

On 2011/9/29 2:07, Vincent Legendre wrote:
Yes you can do all that (but don't know about getting history infos). 
A old post from Jervis Liu linked to more info on REST API here 
http://blog.athico.com/2011/03/atompub-interface-for-guvnor.html and 
http://community.jboss.org/wiki/AtomPubinterfaceforGuvnor


The latest REST doc can be found from here: 
https://hudson.jboss.org/jenkins/job/guvnor/lastSuccessfulBuild/artifact/guvnor-docs/target/docbook/publish/en-US/html_single/index.html#d0e1856

Both package and asset version history info are supported.

Cheers,
Jervis
But you may start by using the existing report. If you go under Guvnor 
and see the package page, in the URL listing part, you will find a 
"documentation" link, which generates a PDF report with all your 
assets (don't know for history).


Le 28/09/2011 19:08, Michael Anstis a écrit :

Have a look at the REST API documented in the user guide.

I suspect you'll be able to get a list of packages, and for each a 
list of assets.


On 28 September 2011 17:59, sanjuk72 > wrote:


I have a following need:

We are maintaining all rules in GUVNOR.
We need to run a weekly report displaying all the Rules and there
related
information like change history.


Qs: How can I access the GUVNOR repository to get this
information. If
anyone can please help.

Thanks

--
View this message in context:

http://drools.46999.n3.nabble.com/Guvnor-Repository-Report-tp3376667p3376667.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users




___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Concurrency problem in PackageClassLoader

2011-09-28 Thread nicolas
Hi,

We are using a single (Drools 5.1.1) Stateless Sessions for the parallel
processing of thousands of facts.

>From time to time we experienced the following error :

org.drools.runtime.rule.ConsequenceException: rule: Priorite - Groupe:
TMK2612G01, P10

  at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
  at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)
  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)
  at
acme.srv.ept.service.impl.traitement.MoteurTraitementDemandes.traiterDemande(MoteurTraitementDemandes.java:121)
(...)
Caused by: java.util.ConcurrentModificationException
  at java.util.HashMap
$AbstractMapIterator.checkConcurrentMod(Unknown Source)
  at java.util.HashMap$AbstractMapIterator.makeNext(Unknown Source)
  at java.util.HashMap$KeyIterator.next(Unknown Source)
  at java.util.HashMap.analyzeMap(Unknown Source)
  at java.util.HashMap.rehash(Unknown Source)
  at java.util.HashMap.rehash(Unknown Source)
  at java.util.HashMap.putImpl(Unknown Source)
  at java.util.HashMap.put(Unknown Source)
  at org.drools.rule.JavaDialectRuntimeData
$PackageClassLoader.loadClass(JavaDialectRuntimeData.java:503)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
  at
acme.srv.ept.regle.Rule_Priorite___Groupe__TMK2612G01__P10_0DefaultConsequenceInvoker.evaluate(Rule_Priorite___Groupe__TMK2612G01__P10_0DefaultConsequenceInvoker.java:29)
  at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
  ... 49 more

We get the same error when we used a pool of Stateless Sessions (serial
access) based on the same KnowledgeBase for the processing.


Thanks,

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Can you remove logging information from BatchExecutionCommand?

2011-09-28 Thread dunnlow
Figured it out.  In case anyone else sees this, the issue was that the bean
that I was sending to the Drools server had a "logger" property, which
XStream was trying to serialize.  I didn't want to do a
myBean.setLogger(null) because I wanted to actually do some logging in the
bean.  So, the solution was to ask XStream to omit that logger property when
it created the XML.

I tried adding the annotation @XStreamOmit before the logger property in my
bean, but that didn't work.  I had to do this:

8<...
  BatchExecutionCommand command =
CommandFactory.newBatchExecution(cmds,"kession1");
  XStream xs = BatchExecutionHelper.newXStreamMarshaller();
  *xs.omitField(com.company.MyBean.class,"logger");*
  String xml = xs.toXML(command);
8<..

-J


--
View this message in context: 
http://drools.46999.n3.nabble.com/Can-you-remove-logging-information-from-BatchExecutionCommand-tp3377109p3377407.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] ClassCastException on .splitNode().constraint()

2011-09-28 Thread cyang
Hi,


I'm using jbpm-flow-5.2.0-SNAPSHOT.jar and got a *ClassCastException *below
with the following Drools flow snippet.  I've tried mvel dialet as well and
got the same error.
*
   
.splitNode(1010).type(Split.TYPE_XOR).name("splitOnShouldActivate")
 .constraint(305, "should activate", "code", "Java",
   
"(Boolean)(context.getVariable(\"shouldActivate\")) == Boolean.TRUE")
 .constraint(2000, "should not activate", "code",
"Java",
   
"(Boolean)(context.getVariable(\"shouldActivate\")) == Boolean.FALSE")
.done

*
Exception in thread "main" java.lang.ClassCastException:
org.jbpm.workflow.core.impl.ConstraintImpl incompatible with
org.jbpm.process.instance.impl.ConstraintEvaluator

at
org.jbpm.workflow.instance.node.SplitInstance.internalTrigger(SplitInstance.java:69)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)

at
org.jbpm.workflow.instance.node.ActionNodeInstance.triggerCompleted(ActionNodeInstance.java:55)

at
org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:51)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)

at
org.jbpm.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:47)

at
org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:162)

at
org.jbpm.workflow.instance.node.StateBasedNodeInstance.triggerCompleted(StateBasedNodeInstance.java:143)

at
org.jbpm.workflow.instance.node.SubProcessNodeInstance.internalTrigger(SubProcessNodeInstance.java:130)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)

at
org.jbpm.workflow.instance.node.ActionNodeInstance.triggerCompleted(ActionNodeInstance.java:55)

at
org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:51)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:185)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:150)

at
org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)

at
org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

at
org.jbpm.workflow.instance.node.CompositeNodeInstance.internalTrigger(CompositeNodeInstance.java:106)

at
org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:122)

at
org.jbpm.workflow.instance.node.ForEachNodeInstance$ForEachSplitNodeInstance.internalTrigger(ForEachNodeInstance.java:97)

 

Thanks in advance.

--
View this message in context: 
http://drools.46999.n3.nabble.com/ClassCastException-on-splitNode-constraint-tp3377117p3377117.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Can you remove logging information from BatchExecutionCommand?

2011-09-28 Thread dunnlow
I am sending a batchexecution command to a drools server:

8<...
  MyBean mb = new MyBean();
  List cmds = new ArrayList();
  InsertObjectCommand insertCmd = (InsertObjectCommand)
CommandFactory.newInsert(mb);
  insertCmd.setOutIdentifier("inserter");
  insertCmd.setEntryPoint("Default");
  cmds.add(insertCmd);
  FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
  cmds.add(fireAllRulesCommand);

  BatchExecutionCommand command =
CommandFactory.newBatchExecution(cmds,"ksession1");

  String xml BatchExecutionHelper.newXstreammarshaller().toXML(command);  
8<...

The xml created by that last line contains A LOT of logging information and
includes characters that seem to be invalid.  (drools server throws a
"ConvertsionException, Invalid character reference: null character not
allowed in XML content" when it reads the XML)

Is there a way to tell the BatchExecutionHelper NOT not to include that
logger information?

ps.  I tried things like turning off the root logger programmatically before
calling.  Also, I tried setting a global parameter "logger" to a null object
(I saw that somewhere) but that didn't work either.
commands.add(CommandFactory.newSetGlobal("logger", null));

Thanks for any insight.
-J

--
View this message in context: 
http://drools.46999.n3.nabble.com/Can-you-remove-logging-information-from-BatchExecutionCommand-tp3377109p3377109.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor Repository Report

2011-09-28 Thread Vincent Legendre
Yes you can do all that (but don't know about getting history infos). A 
old post from Jervis Liu linked to more info on REST API here 
http://blog.athico.com/2011/03/atompub-interface-for-guvnor.html and 
http://community.jboss.org/wiki/AtomPubinterfaceforGuvnor


But you may start by using the existing report. If you go under Guvnor 
and see the package page, in the URL listing part, you will find a 
"documentation" link, which generates a PDF report with all your assets 
(don't know for history).


Le 28/09/2011 19:08, Michael Anstis a écrit :

Have a look at the REST API documented in the user guide.

I suspect you'll be able to get a list of packages, and for each a 
list of assets.


On 28 September 2011 17:59, sanjuk72 > wrote:


I have a following need:

We are maintaining all rules in GUVNOR.
We need to run a weekly report displaying all the Rules and there
related
information like change history.


Qs: How can I access the GUVNOR repository to get this information. If
anyone can please help.

Thanks

--
View this message in context:

http://drools.46999.n3.nabble.com/Guvnor-Repository-Report-tp3376667p3376667.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org 
https://lists.jboss.org/mailman/listinfo/rules-users




___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor Repository Report

2011-09-28 Thread Michael Anstis
Have a look at the REST API documented in the user guide.

I suspect you'll be able to get a list of packages, and for each a list of
assets.

On 28 September 2011 17:59, sanjuk72  wrote:

> I have a following need:
>
> We are maintaining all rules in GUVNOR.
> We need to run a weekly report displaying all the Rules and there related
> information like change history.
>
>
> Qs: How can I access the GUVNOR repository to get this information. If
> anyone can please help.
>
> Thanks
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Guvnor-Repository-Report-tp3376667p3376667.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Date validation in Guvnor

2011-09-28 Thread sanjuk72
I have created DateUtils.java and have all the date functions as part of
that. Import that in Guvnor and use it.

I think you can create functions in Guvnor and use that.

Hope this helps.


--
View this message in context: 
http://drools.46999.n3.nabble.com/Date-validation-in-Guvnor-tp890074p3376679.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Guvnor Repository Report

2011-09-28 Thread sanjuk72
I have a following need:

We are maintaining all rules in GUVNOR.
We need to run a weekly report displaying all the Rules and there related
information like change history.


Qs: How can I access the GUVNOR repository to get this information. If
anyone can please help.

Thanks

--
View this message in context: 
http://drools.46999.n3.nabble.com/Guvnor-Repository-Report-tp3376667p3376667.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Unsatisfied rule fires - Drools bug?

2011-09-28 Thread Wolfgang Laun
2011/9/28 matvey1414 

> Hi,
>
> Thank you for your reply. I will use the Knowledge API going forward.
>
> Can you please explain what you mean by "deviate from the constraint syntax
> as defined with 5.1.1"? What's an example of 5.1.1 syntax,
>

For a complete picture, get the Expert manual of 5.1.1. Most constraint have
to be written as
 
and there's a restrictive list of what is permitted as a , e.g.
   field == (one + 2) // parens are required
or
   field > 42  // OK
and so on.


> and what's an example of a deviation?
>

For instance:
   42 < field
or
  field == one + 2
and so on.

HTH
-W




>
> -Matt
>
> On Tue, Sep 27, 2011 at 5:12 AM, laune [via Drools] <[hidden 
> email]
> > wrote:
>
>> Please use the new "knowledge" API for compiling and building a knowledge
>> (not: rule) base.
>>
>> This bug has been fixed for 5.3.0. It is one of several that may occur
>> when you use 5.2.0 and deviate from the constraint syntax as defined with
>> 5.1.1.
>>
>> -W
>>
>>
>> On 26 September 2011 22:51, matvey1414 <[hidden 
>> email]
>> > wrote:
>>
>>> Hi,
>>>
>>> I am working with Drools to implement a high-profile rules-engine. I have
>>> two rules defined. Clearly, only the first should fire, but both do. Here
>>> is
>>> my DRL:
>>>
>>>
>>> package com.sample
>>>
>>> import com.sample.DroolsTest.Request;
>>>
>>> rule "ExpensiveCanonShopper0"
>>> when
>>>Request( attributeMap["camera0"] == "canon" &&
>>> attributeMap["price0"] >= 500 )
>>> then
>>>System.out.println("ExpensiveCanonShopper0");
>>> end
>>>
>>> rule "ExpensiveCanonShopper1"
>>> when
>>>Request( attributeMap["camera1"] == "canon" &&
>>> attributeMap["price1"] >= 500 )
>>> then
>>>System.out.println("ExpensiveCanonShopper1");
>>> end
>>>
>>> And the Java class to execute it:
>>>
>>> public class DroolsTest {
>>>
>>>@SuppressWarnings({ "rawtypes", "unchecked" })
>>>public static final void main(String[] args) {
>>>try {
>>>//Loading the Rules
>>>System.out.println("Loading rules");
>>>RuleBase ruleBase = readRule();
>>>StatelessSession workingMemory =
>>> ruleBase.newStatelessSession();
>>>
>>>System.out.println("Firing rules");
>>>
>>>Map map = new HashMap();
>>>map.put("camera0", "canon");
>>>map.put("price0", 600);
>>>
>>>Request request = new Request();
>>>request.setAttributeMap(map);
>>>workingMemory.execute(request);
>>>
>>>} catch (Throwable t) {
>>>t.printStackTrace();
>>>}
>>>}
>>>
>>>/**
>>> * Please note that this is the “low level” rule assembly API.
>>> */
>>>private static RuleBase readRule() throws Exception {
>>>//read in the source
>>>Reader source = new FileReader(new File("drl",
>>> "Generated.drl"));
>>>
>>>//optionally read in the DSL (if you are using it).
>>>//Reader dsl = new InputStreamReader(
>>> DroolsTest.class.getResourceAsStream( “/mylang.dsl” ) );
>>>
>>>//Use package builder to build up a rule package.
>>>//An alternative lower level class called “DrlParser” can
>>> also be used…
>>>
>>>PackageBuilder builder = new PackageBuilder();
>>>
>>>//this wil parse and compile in one step
>>>//NOTE: There are 2 methods here, the one argument one is
>>> for normal DRL.
>>>builder.addPackageFromDrl( source );
>>>if (builder.hasErrors()) {
>>>PackageBuilderErrors errors = builder.getErrors();
>>>throw new RuntimeException("Error adding package
>>> to
>>> builder: " + errors.toString());
>>>}
>>>
>>>//Use the following instead of above if you are using a
>>> DSL:
>>>//builder.addPackageFromDrl( source, dsl );
>>>
>>>//get the compiled package (which is serializable)
>>>Package pkg = builder.getPackage();
>>>
>>>//add the package to a rulebase (deploy the rule package).
>>>RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>>>ruleBase.addPackage( pkg );
>>>return ruleBase;
>>>}
>>>
>>>public static class Request {
>>>private Map attributeMap;
>>>
>>>public Map getAttributeMap() {
>>>return attributeMap;
>>>}
>>>
>>>public void setAttributeMap(Map attributeMap) {
>>>this.attributeMap = attributeMap;
>>>}
>

Re: [rules-users] Unsatisfied rule fires - Drools bug?

2011-09-28 Thread matvey1414
Hi,

Thank you for your reply. I will use the Knowledge API going forward.

Can you please explain what you mean by "deviate from the constraint syntax
as defined with 5.1.1"? What's an example of 5.1.1 syntax, and what's an
example of a deviation?

-Matt

On Tue, Sep 27, 2011 at 5:12 AM, laune [via Drools] <
ml-node+s46999n3372058...@n3.nabble.com> wrote:

> Please use the new "knowledge" API for compiling and building a knowledge
> (not: rule) base.
>
> This bug has been fixed for 5.3.0. It is one of several that may occur when
> you use 5.2.0 and deviate from the constraint syntax as defined with 5.1.1.
>
> -W
>
>
> On 26 September 2011 22:51, matvey1414 <[hidden 
> email]
> > wrote:
>
>> Hi,
>>
>> I am working with Drools to implement a high-profile rules-engine. I have
>> two rules defined. Clearly, only the first should fire, but both do. Here
>> is
>> my DRL:
>>
>>
>> package com.sample
>>
>> import com.sample.DroolsTest.Request;
>>
>> rule "ExpensiveCanonShopper0"
>> when
>>Request( attributeMap["camera0"] == "canon" &&
>> attributeMap["price0"] >= 500 )
>> then
>>System.out.println("ExpensiveCanonShopper0");
>> end
>>
>> rule "ExpensiveCanonShopper1"
>> when
>>Request( attributeMap["camera1"] == "canon" &&
>> attributeMap["price1"] >= 500 )
>> then
>>System.out.println("ExpensiveCanonShopper1");
>> end
>>
>> And the Java class to execute it:
>>
>> public class DroolsTest {
>>
>>@SuppressWarnings({ "rawtypes", "unchecked" })
>>public static final void main(String[] args) {
>>try {
>>//Loading the Rules
>>System.out.println("Loading rules");
>>RuleBase ruleBase = readRule();
>>StatelessSession workingMemory =
>> ruleBase.newStatelessSession();
>>
>>System.out.println("Firing rules");
>>
>>Map map = new HashMap();
>>map.put("camera0", "canon");
>>map.put("price0", 600);
>>
>>Request request = new Request();
>>request.setAttributeMap(map);
>>workingMemory.execute(request);
>>
>>} catch (Throwable t) {
>>t.printStackTrace();
>>}
>>}
>>
>>/**
>> * Please note that this is the “low level” rule assembly API.
>> */
>>private static RuleBase readRule() throws Exception {
>>//read in the source
>>Reader source = new FileReader(new File("drl",
>> "Generated.drl"));
>>
>>//optionally read in the DSL (if you are using it).
>>//Reader dsl = new InputStreamReader(
>> DroolsTest.class.getResourceAsStream( “/mylang.dsl” ) );
>>
>>//Use package builder to build up a rule package.
>>//An alternative lower level class called “DrlParser” can
>> also be used…
>>
>>PackageBuilder builder = new PackageBuilder();
>>
>>//this wil parse and compile in one step
>>//NOTE: There are 2 methods here, the one argument one is
>> for normal DRL.
>>builder.addPackageFromDrl( source );
>>if (builder.hasErrors()) {
>>PackageBuilderErrors errors = builder.getErrors();
>>throw new RuntimeException("Error adding package to
>> builder: " + errors.toString());
>>}
>>
>>//Use the following instead of above if you are using a
>> DSL:
>>//builder.addPackageFromDrl( source, dsl );
>>
>>//get the compiled package (which is serializable)
>>Package pkg = builder.getPackage();
>>
>>//add the package to a rulebase (deploy the rule package).
>>RuleBase ruleBase = RuleBaseFactory.newRuleBase();
>>ruleBase.addPackage( pkg );
>>return ruleBase;
>>}
>>
>>public static class Request {
>>private Map attributeMap;
>>
>>public Map getAttributeMap() {
>>return attributeMap;
>>}
>>
>>public void setAttributeMap(Map attributeMap) {
>>this.attributeMap = attributeMap;
>>}
>>}
>> }
>>
>> The output is this, meaning both rules fired:
>> Loading rules
>> Firing rules
>> ExpensiveCanonShopper1
>> ExpensiveCanonShopper0
>>
>> I have two questions:
>>
>> 1. Is this a bug, or am I doing something wrong? Only
>> "ExpensiveCanonShopper0" should fire.
>>
>> 2. I am pretty sure this is somehow related to the fact that I'm using Map
>> attributes, and not POJO to get "price0" and "camera0". My issue is that I
>> won't know the parameters in advance (they are coming in a URL), so I
>> can't
>> pr

Re: [rules-users] Not able to call parameterizied Java method in LHS

2011-09-28 Thread Tinku
rhs part worked ok now..

I am facing one more issue with calling a method in lhs of the rule ..

When I call a method as mentioned below ('getValue' is the method in class
'customObject' and 'numberofObjects' is method in class 'AnotherObject') ;
the drl file has problems in saving in eclipse.
The error says like 'Multiple Markers at this line'

***
rule A

when
$B : customObject() 
$C : AnotherObject()
eval($C.numberofObjects($B.getValue("Database")) > 10) 
then

end



--
View this message in context: 
http://drools.46999.n3.nabble.com/Not-able-to-call-parameterizied-Java-method-in-LHS-tp3372552p3376209.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component.

2011-09-28 Thread Hari Kishan
Done the same way using accumulate ... but still the exception is thrown.

May be the Frequency of Exception occurring is reduced. 

But this time it is occurring from the Accumulate Node.

Some times the Rules Execution is continuing even after the Exception. 
Some times the Exception keeps on repeating continuously for event (may be
here the Context/Working memory is lost).

I am really getting frustrated with this. 
Need to find the permanent solution for this.

Want to know If this is a bug in Drools 5.0.2 . and got fixed in the later
version. If yes please mention the version number . I will check if i can
succeed by replacing the Drools Version in the Mule ESB.


--
View this message in context: 
http://drools.46999.n3.nabble.com/Getting-Exception-while-running-rules-continuously-on-the-Event-Streams-from-Mule-Component-tp3372189p3376137.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component.

2011-09-28 Thread Wolfgang Laun
Same place:
accumulate ( Alarm( ... ) from  , init(...),... )
-W

2011/9/28 HariKishan 

> **
>
> Hi Wolfgang,
>
> ** **
>
> The below code which you wrote is very appropriate but where should we
> mention on which collection we are traversing the conditions on .
>
> ** **
>
> Like in collect 
>
> *$alarms : ArrayList(size>0) from collect ( Alarm( .. ) from
>
> av.getAlarms() )*
>
> ** **
>
> Thanks & Regards,
>
> Hari Kishan T
>
> ** **
>
> -Original Message-
> From: **rules-users-boun...@lists.jboss.org** [mailto:**
> rules-users-boun...@lists.jboss.org**] On Behalf Of Wolfgang Laun
> Sent: Wednesday, September 28, 2011 3:39 PM
> To: **Rules Users List**
> Subject: Re: [rules-users] Getting Exception while running rules
> continuously on the Event Streams from Mule Component.
>
> ** **
>
> Here is an example:
>
> ** **
>
> $av: List() from accumulate ( $a: Alarm( ...select "interesting" alarms...
> ),
>
> init( List alarms = new ArrayList();
> )
>
> action( alarms.add($a); )
>
> reverse( alarms.remove($a); )
>
> result(alarms) )
>
> ** **
>
> To select "interesting" alarms, separate the constraints for fields
>
> "activation" and
>
> "geofenceCustomer" with a comma (which acts like a logical "and").
>
> ** **
>
> -W
>
> ** **
>
> ** **
>
> 2011/9/28 Hari Kishan :
>
> > @wolfgang Yesterday you told me to use accumulate instead of collect. But
> i
>
> > could not find the right way to use accumulate here. Please see below my
> 
>
> > rules when condition [ collect function(Bold & Italic) ] and please tell
> me
>
> > how can i use accumulate there. If possible change the conditional
> element
>
> > to accumulate with appropriate changes. when // "Sensor Data Idem Stream"
> is
>
> > where Mule sends the Sensordata facts // for each Alarm / Sensordata
>
> > combination that is identified via the vehicle id $sd : SensorDataIdem
> ($vid
>
> > : vehicleId) from entry-point "Sensor Data Idem Stream" // Set a
> references
>
> > for later on the initial facts $av : AlarmVehicle(vehicleId == $vid)
> //The
>
> > Condition to be added to get the active Alarms from the List of Alarms**
> **
>
> > eval($av!=null && $av.getAlarms()!=null && $av.getAlarms().size()>0)
> $alarms
>
> > : ArrayList(size>0) from collect ( Alarm( ( (activation ==
>
> > AlarmConstants.ALWAYS_ACTIVE) || (activation ==
>
> > AlarmConstants.ACTIVE_ONLY_ONTOUR && $sd.onTour == true) || (activation
> ==
>
> > AlarmConstants.ACTIVE_ONLY_NOT_ONTOUR && $sd.onTour == false) ||
> (activation
>
> > == AlarmConstants.ACTIVE_ONLY_ONMOVING && $sd.onMove == true) ||
> (activation
>
> > == AlarmConstants.ACTIVE_ON_TIME_WINDOW ) ) && ( ( (geofenceCustomer ==
> 0)
>
> > || (geofenceCustomer == 1 && $sd.inCustomerGeoFence == true) ||
>
> > (geofenceCustomer == 2 && $sd.inCustomerGeoFence == false) ) && (
>
> > (geofenceDepot == 0) || (geofenceDepot == 1 && $sd.inDepotGeoFence ==
> true)
>
> > || (geofenceDepot == 2 && $sd.inDepotGeoFence == false) ) ) ) from
>
> > $av.getAlarms() ) eval($alarms!=null) then ...
>
> > 
>
> > View this message in context: Re: [rules-users] Getting Exception while*
> ***
>
> > running rules continuously on the Event Streams from Mule Component.
>
> > Sent from the Drools: User forum mailing list archive at Nabble.com.
>
> >** **
>
> > ___
>
> > rules-users mailing list
>
> > rules-users@lists.jboss.org
>
> > https://lists.jboss.org/mailman/listinfo/rules-users
>
> >** **
>
> >** **
>
> ___
>
> rules-users mailing list
>
> rules-users@lists.jboss.org
>
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
<<30j_pass-1-1.jpg>>___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component.

2011-09-28 Thread Hari Kishan
The below code which you wrote is very appropriate but where should we
mention on which collection we are traversing the conditions on .


Like in collect 

$alarms : ArrayList(size>0) from collect ( Alarm( .. ) from 
  
av.getAlarms() )

 



--
View this message in context: 
http://drools.46999.n3.nabble.com/Getting-Exception-while-running-rules-continuously-on-the-Event-Streams-from-Mule-Component-tp3372189p3375726.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component.

2011-09-28 Thread HariKishan
Hi Wolfgang,

 

The below code which you wrote is very appropriate but where should we
mention on which collection we are traversing the conditions on .

 

Like in collect 

$alarms : ArrayList(size>0) from collect ( Alarm( .. ) from
av.getAlarms() )

 

Thanks & Regards,

Hari Kishan T

 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: Wednesday, September 28, 2011 3:39 PM
To: Rules Users List
Subject: Re: [rules-users] Getting Exception while running rules
continuously on the Event Streams from Mule Component.

 

Here is an example:

 

$av: List() from accumulate ( $a: Alarm( ...select "interesting" alarms...
),

init( List alarms = new ArrayList(); )

action( alarms.add($a); )

reverse( alarms.remove($a); )

result(alarms) )

 

To select "interesting" alarms, separate the constraints for fields

"activation" and

"geofenceCustomer" with a comma (which acts like a logical "and").

 

-W

 

 

2011/9/28 Hari Kishan :

> @wolfgang Yesterday you told me to use accumulate instead of collect. But
i

> could not find the right way to use accumulate here. Please see below my

> rules when condition [ collect function(Bold & Italic) ] and please tell
me

> how can i use accumulate there. If possible change the conditional element

> to accumulate with appropriate changes. when // "Sensor Data Idem Stream"
is

> where Mule sends the Sensordata facts // for each Alarm / Sensordata

> combination that is identified via the vehicle id $sd : SensorDataIdem
($vid

> : vehicleId) from entry-point "Sensor Data Idem Stream" // Set a
references

> for later on the initial facts $av : AlarmVehicle(vehicleId == $vid) //The

> Condition to be added to get the active Alarms from the List of Alarms

> eval($av!=null && $av.getAlarms()!=null && $av.getAlarms().size()>0)
$alarms

> : ArrayList(size>0) from collect ( Alarm( ( (activation ==

> AlarmConstants.ALWAYS_ACTIVE) || (activation ==

> AlarmConstants.ACTIVE_ONLY_ONTOUR && $sd.onTour == true) || (activation ==

> AlarmConstants.ACTIVE_ONLY_NOT_ONTOUR && $sd.onTour == false) ||
(activation

> == AlarmConstants.ACTIVE_ONLY_ONMOVING && $sd.onMove == true) ||
(activation

> == AlarmConstants.ACTIVE_ON_TIME_WINDOW ) ) && ( ( (geofenceCustomer == 0)

> || (geofenceCustomer == 1 && $sd.inCustomerGeoFence == true) ||

> (geofenceCustomer == 2 && $sd.inCustomerGeoFence == false) ) && (

> (geofenceDepot == 0) || (geofenceDepot == 1 && $sd.inDepotGeoFence ==
true)

> || (geofenceDepot == 2 && $sd.inDepotGeoFence == false) ) ) ) from

> $av.getAlarms() ) eval($alarms!=null) then ...

> 

> View this message in context: Re: [rules-users] Getting Exception while

> running rules continuously on the Event Streams from Mule Component.

> Sent from the Drools: User forum mailing list archive at Nabble.com.

> 

> ___

> rules-users mailing list

> rules-users@lists.jboss.org

> https://lists.jboss.org/mailman/listinfo/rules-users

> 

> 

___

rules-users mailing list

rules-users@lists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users

<>___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component.

2011-09-28 Thread Wolfgang Laun
Here is an example:

$av: List() from accumulate ( $a: Alarm( ...select "interesting" alarms... ),
init( List alarms = new ArrayList(); )
action( alarms.add($a); )
reverse( alarms.remove($a); )
result(alarms) )

To select "interesting" alarms, separate the constraints for fields
"activation" and
"geofenceCustomer" with a comma (which acts like a logical "and").

-W


2011/9/28 Hari Kishan :
> @wolfgang Yesterday you told me to use accumulate instead of collect. But i
> could not find the right way to use accumulate here. Please see below my
> rules when condition [ collect function(Bold & Italic) ] and please tell me
> how can i use accumulate there. If possible change the conditional element
> to accumulate with appropriate changes. when // "Sensor Data Idem Stream" is
> where Mule sends the Sensordata facts // for each Alarm / Sensordata
> combination that is identified via the vehicle id $sd : SensorDataIdem ($vid
> : vehicleId) from entry-point "Sensor Data Idem Stream" // Set a references
> for later on the initial facts $av : AlarmVehicle(vehicleId == $vid) //The
> Condition to be added to get the active Alarms from the List of Alarms
> eval($av!=null && $av.getAlarms()!=null && $av.getAlarms().size()>0) $alarms
> : ArrayList(size>0) from collect ( Alarm( ( (activation ==
> AlarmConstants.ALWAYS_ACTIVE) || (activation ==
> AlarmConstants.ACTIVE_ONLY_ONTOUR && $sd.onTour == true) || (activation ==
> AlarmConstants.ACTIVE_ONLY_NOT_ONTOUR && $sd.onTour == false) || (activation
> == AlarmConstants.ACTIVE_ONLY_ONMOVING && $sd.onMove == true) || (activation
> == AlarmConstants.ACTIVE_ON_TIME_WINDOW ) ) && ( ( (geofenceCustomer == 0)
> || (geofenceCustomer == 1 && $sd.inCustomerGeoFence == true) ||
> (geofenceCustomer == 2 && $sd.inCustomerGeoFence == false) ) && (
> (geofenceDepot == 0) || (geofenceDepot == 1 && $sd.inDepotGeoFence == true)
> || (geofenceDepot == 2 && $sd.inDepotGeoFence == false) ) ) ) from
> $av.getAlarms() ) eval($alarms!=null) then ...
> 
> View this message in context: Re: [rules-users] Getting Exception while
> running rules continuously on the Event Streams from Mule Component.
> Sent from the Drools: User forum mailing list archive at Nabble.com.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] DROOLS PLANNER - getting started

2011-09-28 Thread Geoffrey De Smet

Either create a new eclipse project from the directory examples/sources 
(from the download zip) and add the jars from the binaries directory 
(not the examples/binaries directory!)
Or install the m2eclipse plugin and open the examples/sources/pom.xml 
(from the download zip).

Afterwards, just run DroolsPlannerExamplesApp.

Op 28-09-11 11:39, vik schreef:
> Hellow,
> I also a new with Drools Planner ... how I can try the examples on my
> eclipse?
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/DROOLS-PLANNER-getting-started-tp3030567p3375541.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>

-- 
With kind regards,
Geoffrey De Smet


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Getting Exception while running rules continuously on the Event Streams from Mule Component.

2011-09-28 Thread Hari Kishan
@wolfgang

Yesterday you told me to use accumulate instead of collect.
But i could not find the right way to use accumulate here.
Please see below my rules when condition [ collect function(Bold & Italic) ]
and please tell me how can i use accumulate there. If possible change the
conditional element to accumulate with appropriate changes.

when
// "Sensor Data Idem Stream" is where Mule sends the Sensordata facts
// for each Alarm / Sensordata combination that is identified via the
vehicle id
$sd : SensorDataIdem ($vid : vehicleId) from entry-point "Sensor Data
Idem Stream"

// Set a references for later on the initial facts 
$av : AlarmVehicle(vehicleId == $vid)   

//The Condition to be added to get the active Alarms from the List of
Alarms
eval($av!=null && $av.getAlarms()!=null && $av.getAlarms().size()>0)

/*$alarms : ArrayList(size>0) from collect ( 
Alarm(  
(
(activation == 
AlarmConstants.ALWAYS_ACTIVE) 
||  (activation == 
AlarmConstants.ACTIVE_ONLY_ONTOUR && $sd.onTour
== true)
||  (activation == 
AlarmConstants.ACTIVE_ONLY_NOT_ONTOUR &&
$sd.onTour == false)
||  (activation == 
AlarmConstants.ACTIVE_ONLY_ONMOVING && $sd.onMove
== true)
||  (activation == 
AlarmConstants.ACTIVE_ON_TIME_WINDOW )
)
&&
(   
(
(geofenceCustomer == 0) 
||  (geofenceCustomer == 1 && 
$sd.inCustomerGeoFence == true)
||  (geofenceCustomer == 2 && 
$sd.inCustomerGeoFence == false)
) 
&&  
(
(geofenceDepot == 0) 
||  (geofenceDepot == 1 && $sd.inDepotGeoFence 
== true)
||  (geofenceDepot == 2 && $sd.inDepotGeoFence 
== false)
) 
) 
) 
from $av.getAlarms() )*/

eval($alarms!=null) 



then 
...


--
View this message in context: 
http://drools.46999.n3.nabble.com/Getting-Exception-while-running-rules-continuously-on-the-Event-Streams-from-Mule-Component-tp3372189p3375564.html
Sent from the Drools: User forum mailing list archive at Nabble.com.___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] DROOLS PLANNER - getting started

2011-09-28 Thread vik
Hellow, 
I also a new with Drools Planner ... how I can try the examples on my
eclipse? 

--
View this message in context: 
http://drools.46999.n3.nabble.com/DROOLS-PLANNER-getting-started-tp3030567p3375541.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users