Implement timer in rule
by james corrigan
Hi All,
I am trying to implement a timer in a rule so that it executes every 15min i
have the following code:
rule " When average temperature is greater than 19 turn on fans"
timer(int:0 15m)
when
$t : Temperature($room : room)
$fan : Fan( room == $room )
then
"i need to implement this yet
end
I am getting on the timer: "[ERR 101]Line 61:0 no viable alternative at
input 'timer' in rule ......
I read example 2.12. Example timer attribute uses from
https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/t...
and this is how it says to implement a timer.
Any help is greatly appreciated.
Kind regards,
James.
14 years, 5 months
FW: Drools 5.1.0.M2 - WorkItemNodeInstance --Listeners can't get hold of WorkItem object
by Vijay K Pandey
Hi @Salaboy,
Did you get a chance to look into this?
Thanks
Vijay
From: Vijay K Pandey
Sent: Thursday, July 15, 2010 1:26 PM
To: 'rules-users(a)lists.jboss.org'
Subject: FW: [rules-users] Drools 5.1.0.M2 - WorkItemNodeInstance --Listeners can't get hold of WorkItem object
Hi @Salaboy,
I am not sure if you received the email below. Thanks for looking into this.
Vijay
From: Vijay K Pandey
Sent: Tuesday, July 13, 2010 8:53 AM
To: 'Mauricio Salatino'
Subject: RE: [rules-users] Drools 5.1.0.M2 - WorkItemNodeInstance --Listeners can't get hold of WorkItem object
Thanks for a quick response. I added the Transaction Manager piece of code but the problem still persists. Also it uses the attached persistence.xml file which is placed under META-INF directory that has the correct transaction manager look up class.
Thanks
Vijay
From: Mauricio Salatino [mailto:salaboy@gmail.com]
Sent: Tuesday, July 13, 2010 6:40 AM
To: Vijay K Pandey
Subject: Re: [rules-users] Drools 5.1.0.M2 - WorkItemNodeInstance --Listeners can't get hold of WorkItem object
I've just take a quick look to your file and I notice (without running it) that you didn't set the TransactionManager property to your Environment:
env.set( EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager() );
You also need to have the reference to bitronix inside your persistence.xml file:
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
Can you try this and let me know if it fix your problem?
Greetings
On Tue, Jul 13, 2010 at 12:43 AM, Vijay K Pandey <VPandey(a)mdes.ms.gov<mailto:VPandey@mdes.ms.gov>> wrote:
Thanks Salaboy for looking into this.
Here is the Junit Test case(java file attached) I created for this problem.
Line # 129 fails.
Please do let me know if I am doing something wrong or the fix has some issues or maybe there is some other way out to get hold of the "WorkItem" object in the process event listener.
Thanks
Vijay
From: rules-users-bounces(a)lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org> [mailto:rules-users-bounces@lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>] On Behalf Of Salaboy
Sent: Friday, July 09, 2010 11:11 AM
To: Rules Users List
Subject: Re: [rules-users] Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object
I would like to take a look on this issue. Can you provide me a test case that show the problem?
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Mauricio "Salaboy" Salatino -
On Jul 9, 2010, at 12:43, Vijay K Pandey <VPandey(a)mdes.ms.gov<mailto:VPandey@mdes.ms.gov>> wrote:
I guess this problem was due to a fix done in WorkItemNodeInstance? Is this the correct behavior? If yes how do we get hold of "WorkItem" instance in the attached listeners?
http://fisheye.jboss.org/browse/JBossRules/trunk/drools-core/src/main/jav...
Thanks
Vijay
From: Vijay K Pandey
Sent: Tuesday, June 15, 2010 9:20 AM
To: 'Rules Users List'
Subject: RE: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object
Any one on this issue? Any Drools Flow expert?
Appreciate your time for taking a look at it.
Thanks
Vijay
From: Vijay K Pandey
Sent: Thursday, June 10, 2010 12:03 PM
To: 'Rules Users List'
Subject: RE: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object
Should I log this as a JIRA ticket.
Thanks
Vijay
From: Vijay K Pandey
Sent: Wednesday, June 09, 2010 9:57 AM
To: 'Rules Users List'
Subject: Drools 5.1.0.M2 - WorkItemNodeInstance -- Listeners can't get hold of WorkItem object
Hi,
There is a change done in Drools 5.1.0.M2 - org.drools.workflow.instance.node.WorkItemNodeInstance class in the method
public void triggerCompleted(WorkItem workItem) at line 196 which is setting the workItemId as -1
this.workItemId = -1;
Due to the above change the listeners which are attached to the "complete" event of the work item - such as the method below
public void beforeNodeLeft(ProcessNodeLeftEvent event) are not able to get hold of the associated workitem object as it returns null.
Is there any specific reason that workItemId is set to -1 even before the associated listeners get triggered or is this a bug?
If it was an intended change then how do I get hold of the "WorkItem" object in the attached listeners.
Thanks
Vijay
p.s This change was not there in the snapshot of 18th April 2010 which I was earlier working on. Above is the only change in this class from the snapshot of 18th April and 5.1.0.M2
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
14 years, 5 months
How to Iterate list in drools
by Dinesh kumar
Hi,
I am facing problems in iterating a list in guvnor.
I tried the following code and it worked.
import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when
ClaimRegistration($ailmentList : ailmentListFromScreen)
then
for(String ailment : (ArrayList<String>) $ailmentList){
System.out.println("ailment "+ailment);
}
System.out.println("then");
end
But my requirement is to iterate the list in the when block and process
something based on the data in the list.
It should be something like
import java.util.ArrayList;
rule createValidationReport
dialect 'java'
when
ClaimRegistration($ailmentList : ailmentListFromScreen)
for(String ailment : (ArrayList<String>) $ailmentList){
System.out.println("ailment "+ailment);
// My condition needs to be evaluated here
}
then
System.out.println("then");
end
Need help on this issue. Is this possible in Drools?
kindly advice.
Regards,
Dinesh
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/How-to-Iterate-list-i...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
Rules integration with Java -need help
by Dinesh kumar
Hi,
Need help in integrating guvnor with my java application.
I have the set rules to executed for a particular module as individual
packages within guvnor. To fire these rules, I have separate properties file
specifying the URL of each package and mention it within the application as
below.
For module1:
Properties properties = new Properties();
properties.load(new FileInputStream(module1PropertiesFilePath));
RuleAgent agent = RuleAgent.newRuleAgent(properties);
RuleBase ruleBase = agent.getRuleBase();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(module1Object);
workingMemory.fireAllRules();
For module2:
Properties properties = new Properties();
properties.load(new FileInputStream(module2PropertiesFilePath));
RuleAgent agent = RuleAgent.newRuleAgent(properties);
RuleBase ruleBase = agent.getRuleBase();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(module2Object);
workingMemory.fireAllRules();
My properties file looks like this. There will be one properties file for
each module.
##
## RuleAgent configuration file example
##
#setting this means the rulebase will be created fresh whenever there are
#changes
newInstance=true
#this points to a binary compiled rule package, you can have spaces
#seperating multiple files
#file=/foo/bar/boo.pkg /foo/bar/boo2.pkg
#this specifies that packages may appear in a directory
#it will pick up whatever files are dumped in there (.pkg files like above)
#dir=/my/dir
#this specifies a list of urls for packages - these urls
#are those that are exposed by the BRMS
url=
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/Modu...
#the following can be used with the urls to keep a local cache
#so if the runtime server is restarted, the BRMS does not need
#to be available
#localCacheDir=
#this specifies the frequency at which the sources will be checked for
#changes (in seconds). If you don't set this, it will mean that you have
#to manually poll
poll=30
#this specifies the name of this config, necessary in case logging is used.
name=MyConfig
Instead of specifying the url in the properties file, can i directly have
the url in my java..
How to directly specify the url in java instead of using properties file?
Any suggestions will be of great help..
Regards,
Dinesh
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-integration-wit...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
fireAllRules performance
by sjoo822
I have several thousand objects that gets inserted into a statefull knowledge
session as show below:
for (Item item : itemList)
{
session.insert(item);
}
session.fireAllRules();
Assuming that all the conditions in the rules only concern with one item at
a time, will there be a big performance difference if I changed the above to
as shown below?
for (Item item : itemList)
{
session.insert(item);
session.fireAllRules();
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/fireAllRules-performa...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
ArrayList in Guvnor 5.1 M2
by james corrigan
Hi All
I have built the following rule in version 5.0 with no errors:
rule "When average temperature is greater than 19"
lock-on-active true
when
$t : ArrayList() from
collect(Temperature()) //store all temperature
objects in an arraylist
$average: Number(doubleValue>19) from
accumulate(Temperature($val:value),average($val))
//calculate the average temperature
$f : ArrayList() from collect(Fan())
then
System.out.println($average);
turnOnFans($f); //function -> send arraylist of fan objects to
function
end
but when i try to build in version 5.1 i get a
java.lang.ArrayStoreException.
Any help much appreciated.
Kind regards,
James.
14 years, 5 months
Re: [rules-users] StackOverflowError when serializing KnowledgeBase
by Andargor
Sorry, forgot to mention, I have tried 5.1.0M1, and yesterday's snapshot.
--- On Thu, 7/22/10, Andargor <andargor(a)yahoo.com> wrote:
> From: Andargor <andargor(a)yahoo.com>
> Subject: StackOverflowError when serializing KnowledgeBase
> To: rules-users(a)lists.jboss.org
> Date: Thursday, July 22, 2010, 8:10 PM
> Hello,
>
> After adding a few hundred rules, and with the same code,
> KnowledgeBase serialization has started to generate
> StackOverflowError. I have increased the VM stack size as a
> workaround, but I was hoping to implement something more
> robust.
>
> I specifically need to serialize the KnowledgeBase, and not
> the session.
>
> I'm using this code:
>
> private void dumpKnowledgeBase(String file,
> KnowledgeBase kbase) {
> try {
>
> FileOutputStream ostream = new
> FileOutputStream(file);
>
> DroolsObjectOutputStream p = new
> DroolsObjectOutputStream(ostream);
>
> p.writeObject(kbase);
>
> p.flush();
>
> ostream.close();
> }
> catch
> (Exception e) {
>
> System.err.println(e);
>
> e.printStackTrace();
>
> System.err.println("Could not write
> knowledge base "+file);
> }
> }
>
>
> This is due to writeObject recursion? Any ideas?
>
> A.
>
>
>
>
14 years, 5 months
Detecting an expired Event
by Jean-Philippe Steinmetz
Hello everyone,
I'm working on a Drools system that uses stream mode to handle incoming
events from clients and I am trying to adapt some existing code to
Drools. I'm unsure if it's fully applicable but I'm hoping someone can
shed light on to it.
My current execution path is...
1. Client generates an event
2. Server receives event and places it into a timer for a
specified time.
3. When the timer is up the server notifies the client.
>From what I can see you can determine if event A occurs after event B
but I don't see any way that lets you know when event B finishes on its
own. Is this even possible? Thanks.
Cheers,
Jean-Philippe
14 years, 5 months