Re: [rules-users] Basic doubt regarding Drools Fusion - @expires

2011-03-17 Thread Makewise - Vitor Rui Mendonça
Edison, first of all, thanks for your quick reply!

Those initial words caught my attention, although: “By default, Drools does not 
start any internal thread”…

What do you mean “by default”?
I know there are ways to force the event to be expired but I’m looking for a 
solution that doesn’t involve to write new rules.

For example, I’m using this kind of solution:

declare A

  @role( event )

  @expires( 1h )

end
rule "internal - expiring A"
  timer(int:1h)
when
  $a : A() from entry-point "incoming"
then
  retract($a);
end

Although this solution works (from Drools 5.1), I’m forced to write a rule to 
expire an event that’s supposed to be expired initially.
There’s a simpler way to do this? I’m thinking correctly?

Once again, thanks!



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt<http://www.makewise.pt>
Uma empresa: Grupo Sousa Pedro<http://www.sousapedro.com>

[cid:image002.jpg@01CBE493.E9E167A0]







Declaração:
A informação contida nesta mensagem, e os ficheiros anexos, é privilegiada e 
confidencial, destinando-se exclusivamente ao(s) destinatário(s).Se não é o 
destinatário (ou o responsável pela sua entrega ao destinatário) e recebeu a 
mesma por engano, fica notificado que é estritamente proibido reproduzir, 
guardar ou distribuir toda ou qualquer parte desta mensagem e ficheiros 
anexos.Por favor reencaminhe a mensagem para o responsável pelo seu envio ou 
contacte-nos por telefone e elimine a mensagem e ficheiros anexos do seu 
computador,sem os reproduzir.

Disclaimer:
The information contained in this message, and any files attached, is 
privileged and confidential, and intended exclusively for the included 
addresses.If you are not the intended recipient (or the person responsible for 
delivering to the intended recipient) and received this message by mistake, be 
aware that copy, storage, distribution or any other use of all or part of this 
message and the files attached is strictly prohibited. Please notify the sender 
by reply e-mail or contact us by telephone and delete this message and the 
files attached, without retaining a copy.

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: quarta-feira, 16 de Março de 2011 18:38
To: Rules Users List
Subject: Re: [rules-users] Basic doubt regarding Drools Fusion - @expires


   By default, Drools does not start any internal thread, so that you can embed 
it in non-multithread applications or in JEE containers. That means that the 
actual release of events in such cases depends on triggers. In your example, 
after 1h has passed, whenever something happens to the session (a new rule is 
fired, a new event is inserted, the session clock is advanced, etc), the event 
will be expired as part of the action. Remember though that it only happens 
when running in STREAM mode. In CLOUD mode, event garbage collection does not 
make sense and will not happen.

  Edson
2011/3/16 Makewise - Vitor Rui Mendonça 
mailto:vitor.mendo...@brisa.pt>>
Hi all!

I’ve got a really basic doubt… I’ve read several documentation regarding it but 
I think I need some advice here…

Imagine that I have an event:
declare A
  @role( event )
  @expires( 1h )
end

On my Java code, I call “fireAllRules()” method every time that I put an event 
into the working memory.

My doubt: When does event A expires?

a)  One hour after it was inserted (time-based and without the 
“fireAllRules()” method call) or

b)  by calling “fireAllRules()” method (event-based)

T.I.A.



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt<http://www.makewise.pt>
Uma empresa: Grupo Sousa Pedro<http://www.sousapedro.com>

[cid:image002.jpg@01CBE493.E9E167A0]






Declaração:
A informação contida nesta mensagem, e os ficheiros anexos, é privilegiada e 
confidencial, destinando-se exclusivamente ao(s) destinatário(s).Se não é o 
destinatário (ou o responsável pela sua entrega ao destinatário) e recebeu a 
mesma por engano, fica notificado que é estritamente proibido reproduzir, 
guardar ou distribuir toda ou qualquer parte desta mensagem e ficheiros 
anexos.Por favor reencaminhe a mensagem para o responsável pelo seu envio ou 
contacte-nos por telefone e elimine a mensagem e ficheiros anexos do seu 
computador,sem os reproduzir.

Disclaimer:
The information contained in this message, and any files attached, is 
privileged and confidential, and intended exclusively for the included 
addre

[rules-users] Basic doubt regarding Drools Fusion - @expires

2011-03-16 Thread Makewise - Vitor Rui Mendonça
Hi all!

I’ve got a really basic doubt… I’ve read several documentation regarding it but 
I think I need some advice here…

Imagine that I have an event:
declare A
  @role( event )
  @expires( 1h )
end

On my Java code, I call “fireAllRules()” method every time that I put an event 
into the working memory.

My doubt: When does event A expires?

a)  One hour after it was inserted (time-based and without the 
“fireAllRules()” method call) or

b)  by calling “fireAllRules()” method (event-based)

T.I.A.



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro

[cid:image002.jpg@01CBE3EF.C9596900]







Declaração:
A informação contida nesta mensagem, e os ficheiros anexos, é privilegiada e 
confidencial, destinando-se exclusivamente ao(s) destinatário(s).Se não é o 
destinatário (ou o responsável pela sua entrega ao destinatário) e recebeu a 
mesma por engano, fica notificado que é estritamente proibido reproduzir, 
guardar ou distribuir toda ou qualquer parte desta mensagem e ficheiros 
anexos.Por favor reencaminhe a mensagem para o responsável pelo seu envio ou 
contacte-nos por telefone e elimine a mensagem e ficheiros anexos do seu 
computador,sem os reproduzir.

Disclaimer:
The information contained in this message, and any files attached, is 
privileged and confidential, and intended exclusively for the included 
addresses.If you are not the intended recipient (or the person responsible for 
delivering to the intended recipient) and received this message by mistake, be 
aware that copy, storage, distribution or any other use of all or part of this 
message and the files attached is strictly prohibited. Please notify the sender 
by reply e-mail or contact us by telephone and delete this message and the 
files attached, without retaining a copy.

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


[rules-users] Event expiration doubt

2010-05-19 Thread Makewise - Vitor Rui Mendonça
Hi!

 

I've detected some problems in my rules regarding event expiration but I can't 
understand why. Maybe someone with more experience could help me out.

 

I think the example is quite simple: the application receives transactions. The 
lack of transactions for an hour should raise an alarm. If there's a 
transaction when the alarm is on, then the application should rearm, clear the 
alarm state and check for lack of transactions.

 

The rules:

package com.company.application;

 

import com.company.application.Notifier;

import com.company.application.Notification;

import com.company.application.Transaction;

 

dialect "java"

 

# event which represents an alarm state

declare NoTransactions

  @role( event )

  dummy1: long

end

 

# event which represents the start of drools engine

declare EngineStarted

  @role( event )

  dummy2 : long

end

 

# event which represents the need to check for absence of transactions for the 
first hour

declare CheckFirstTransaction

  @role( event )

  @expire( 1h )

  dummy3: long

end

 

# event which represents a Transaction

declare Transaction

  @role( event )

  @expires( 1h )

end

 

# Notification System

global Notifier notifier;

 

 

rule "***start***"

when

  not( EngineStarted() )

then

  insert( new EngineStarted() );

  insert( new CheckFirstTransaction() );

end

 

 

rule "***notrx_after_start***"

when

  $engineStarted : EngineStarted()

  $checkFirstTransaction : CheckFirstTransaction() 

  not( NoTransactions() )

  not( Transaction( this after[0s,1h] $engineStarted ) from entry-point 
"incoming" ) 

then

  insert ( new NoTransactions() );

  retract( $checkFirstTransaction );

  notifier.send( new Notification( "ALARM" ) );

end

 

 

rule "***notrx_after_trx***"

when

  EngineStarted()

  not( NoTransactions() )

  $transaction: Transaction() from entry-point "incoming"

  not( Transaction( this != $transaction, this after [0s,1h] $transaction ) 
from entry-point "incoming" ) 

then

  insert( new NoTransactions());

  notifier.send( new Notification( "ALARM" ) );

end

 

 

rule "***rearm***"

when

  EngineStarted()

  $noTransactions : NoTransactions()

  $transaction: Transaction( this after $noTransactions ) from entry-point 
"incoming"

then

  retract( $noTransactions );

  notifier.send( new Notification( "REARM" ) );

end

 

 

The unit test:

kSession.fireAllRules(); // needed to detect lack of transactions in the first 
hour

 

/* here, "***start***" rule fires => "EngineStarted" and 
"CheckFirstTransaction" inserted */

 

clock.advanceTime( 1, TimeUnit.HOURS );

 

/* here, "***notrx_after_start***" rule fires => "NoTransactions" inserted, 
"CheckFirstTransaction" retracted */

 

clock.advanceTime(10, TimeUnit.MINUTES );

 

entryPoint.insert( new Transaction() );

 

/* before inserting "Transaction" into EntryPoint, "NoTransactions" is 
retracted */

 

kSession.fireAllRules();

 

 

The problem:

After inserting the last transaction, automatically the NoTransactions event is 
retracted. Debugging inside drools-core project, I've discovered that the event 
was retracted because expiration (WorkingMemoryReteExpireAction on 
actionQueue). 

I've also found some more explain how expiration events works, by Edison 
(http://drools-java-rules-engine.46999.n3.nabble.com/Events-are-not-automatically-expiring-from-working-memory-td61127.html).
 That shed some light on *when* the event is retracted but I don't understand 
*why* it's retracted.

 

 

Thanks In Advance!

 

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt  
Uma empresa: Grupo Sousa Pedro   

 



 

 

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


[rules-users] Entry-Points can cause NullPointerExceptionand/or no rule firing

2010-05-18 Thread Makewise - Vitor Rui Mendonça
Hi!

 

Anyone with some other thought about this issue?

I'm running out of ideas...

 

Best regards,

 

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt <http://www.makewise.pt> 
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  

 



 

Vitor,

Please stop replying to posts with unrelated topics and just changing the 
title, it messes up the threaded view in most people's email app. See here for 
more details on netiquette:
http://www.jboss.org/drools/lists.html <http://www.jboss.org/drools/lists.html> 

Mark
On 14/05/2010 15:51, Makewise - Vitor Rui Mendonça wrote: 

Hi Greg!

 

Thanks for your quick answer.

I'm having some trouble with absence of events in Drools (I've send some emails 
on the mailing list regarding that) and I personally think it's some kind of 
bug (mine or, probably, drools).

 

So, I'm looking for some help. Instead of explaining all over again, I just 
point the issue out.

 

Sorry about this mess, too much time around this problem J

 

Thanks, once again!

 



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  





 

 

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: sexta-feira, 14 de Maio de 2010 15:31
To: Rules Users List
Subject: Re: [rules-users] Entry-Points can cause NullPointerExceptionand/or no 
rule firing

 

JIRA issues are for reporting bugs in drools.  Is there a bug you're reporting 
or do you want help with this particular problem?

--- On Fri, 5/14/10, Makewise - Vitor Rui Mendonça  
<mailto:vitor.mendo...@brisa.pt>  wrote:


From: Makewise - Vitor Rui Mendonça  
<mailto:vitor.mendo...@brisa.pt> 
Subject: [rules-users] Entry-Points can cause NullPointerException and/or no 
rule firing
To: "Rules Users List"  
<mailto:rules-users@lists.jboss.org> 
Date: Friday, May 14, 2010, 8:40 AM

Hi again.

 

First of all, I'm running Drools 5.1.0.SNAPSHOT on Windows and Eclipse 3.4.

 

I've submitted a Jira Issue (https://jira.jboss.org/jira/browse/JBRULES-2511):

"

I've got a system that receives transactions. I want to implement the following 
rules: 
- raise an alarm(alarm event) when there aren't any transaction for an hour (or 
more); 
- if there's an alarm, no more alarms should be raised; 
- if there's an alarm and the system receives a transaction, that alarm should 
be retracted and the system should send an recovery event. 

I've implemented the rules this way: 
- ***start*** rule to insert an "EngineStart" event when the rules engine 
starts 
- ***notrx_after_start*** rule to detect absence of transactions during the 
first hour 
- ***notrx_after_trx*** rule to detect absence of transactions (during one 
hour) after last transaction 
- ***rearm*** rule to detect transactions and rearm the system. 

I made a Maven project with junits, which inserts transactions at specific 
time, in order to raise the desired events. 

Two set of tests were made: 
- the rules defined in "default" entry-point: the correspondent junit gives a 
NullPointerException in DefaultAgenda 
- the rules defined in "incoming" entry-point: the correspondent junit doesn't 
activate the ***rearm*** rule

"

 

The issue has an attachment with junits and rules to play with.

 

T.I.A.

 



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  





 


-Inline Attachment Follows-

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

 

 
 
___
rules-users mailing list
rules-users@lists.jboss.org <mailto:rules-users@lists.jboss.org> 
https://lists.jboss.org/mailman/listinfo/rules-users 
<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] Entry-Points can cause NullPointerExceptionand/or no rule firing

2010-05-14 Thread Makewise - Vitor Rui Mendonça
Hi Greg!

 

Thanks for your quick answer.

I’m having some trouble with absence of events in Drools (I’ve send some emails 
on the mailing list regarding that) and I personally think it’s some kind of 
bug (mine or, probably, drools).

 

So, I’m looking for some help. Instead of explaining all over again, I just 
point the issue out.

 

Sorry about this mess, too much time around this problem J

 

Thanks, once again!

 

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt <http://www.makewise.pt> 
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  

 



 

 

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: sexta-feira, 14 de Maio de 2010 15:31
To: Rules Users List
Subject: Re: [rules-users] Entry-Points can cause NullPointerExceptionand/or no 
rule firing

 

JIRA issues are for reporting bugs in drools.  Is there a bug you're reporting 
or do you want help with this particular problem?

--- On Fri, 5/14/10, Makewise - Vitor Rui Mendonça  
wrote:


From: Makewise - Vitor Rui Mendonça 
Subject: [rules-users] Entry-Points can cause NullPointerException and/or no 
rule firing
To: "Rules Users List" 
Date: Friday, May 14, 2010, 8:40 AM

Hi again.

 

First of all, I’m running Drools 5.1.0.SNAPSHOT on Windows and Eclipse 3.4.

 

I’ve submitted a Jira Issue (https://jira.jboss.org/jira/browse/JBRULES-2511 
<https://jira.jboss.org/jira/browse/JBRULES-2511> ):

“

I've got a system that receives transactions. I want to implement the following 
rules: 
- raise an alarm(alarm event) when there aren't any transaction for an hour (or 
more); 
- if there's an alarm, no more alarms should be raised; 
- if there's an alarm and the system receives a transaction, that alarm should 
be retracted and the system should send an recovery event. 

I've implemented the rules this way: 
- ***start*** rule to insert an "EngineStart" event when the rules engine 
starts 
- ***notrx_after_start*** rule to detect absence of transactions during the 
first hour 
- ***notrx_after_trx*** rule to detect absence of transactions (during one 
hour) after last transaction 
- ***rearm*** rule to detect transactions and rearm the system. 

I made a Maven project with junits, which inserts transactions at specific 
time, in order to raise the desired events. 

Two set of tests were made: 
- the rules defined in "default" entry-point: the correspondent junit gives a 
NullPointerException in DefaultAgenda 
- the rules defined in "incoming" entry-point: the correspondent junit doesn't 
activate the ***rearm*** rule

“

 

The issue has an attachment with junits and rules to play with.

 

T.I.A.

 



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt <http://www.makewise.pt> 
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  





 


-Inline Attachment Follows-

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users 
<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] Entry-Points can cause NullPointerException and/or no rule firing

2010-05-14 Thread Makewise - Vitor Rui Mendonça
Hi again.

 

First of all, I'm running Drools 5.1.0.SNAPSHOT on Windows and Eclipse 3.4.

 

I've submitted a Jira Issue (https://jira.jboss.org/jira/browse/JBRULES-2511):

"

I've got a system that receives transactions. I want to implement the following 
rules: 
- raise an alarm(alarm event) when there aren't any transaction for an hour (or 
more); 
- if there's an alarm, no more alarms should be raised; 
- if there's an alarm and the system receives a transaction, that alarm should 
be retracted and the system should send an recovery event. 

I've implemented the rules this way: 
- ***start*** rule to insert an "EngineStart" event when the rules engine 
starts 
- ***notrx_after_start*** rule to detect absence of transactions during the 
first hour 
- ***notrx_after_trx*** rule to detect absence of transactions (during one 
hour) after last transaction 
- ***rearm*** rule to detect transactions and rearm the system. 

I made a Maven project with junits, which inserts transactions at specific 
time, in order to raise the desired events. 

Two set of tests were made: 
- the rules defined in "default" entry-point: the correspondent junit gives a 
NullPointerException in DefaultAgenda 
- the rules defined in "incoming" entry-point: the correspondent junit doesn't 
activate the ***rearm*** rule

"

 

The issue has an attachment with junits and rules to play with.

 

T.I.A.

 

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro   

 



 

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


Re: [rules-users] Activation doubt

2010-05-13 Thread Makewise - Vitor Rui Mendonça
Hi again!

 

The problem occurred in Drools 5.1.0 M1 but I've tried with the latest snapshot 
(2010-05-11) and worked fine.

 

Thanks for your patience!

 

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  

 



 

 

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Makewise - Vitor Rui 
Mendonça
Sent: quinta-feira, 13 de Maio de 2010 10:24
To: Rules Users List
Subject: [rules-users] Activation doubt

 

Hi folks!

 

I'm having some trouble to understand activations.

My system receives transactions and I want to detect periods of time without 
transactions. If I don't have transactions for an hour, I want to sound an 
alarm.

 

I've wrote the following rules just to see how Drools works (I've tried sliding 
windows also but without success):

declare NoTransactions

  @role( event )

  timestamp: long

end

declare EngineStart

  @role( event )

  timestamp: long

end

declare Transaction

  @role( event )

  @expires( 1h )

end

rule "***start***"

  when

not( EngineStart() ) 

  then

insert( new EngineStart() );

System.out.println("engine started");

end

rule "***notrx_after_start***"

  when

$engineStart : EngineStart()

not( NoTransactions() )

not(Transaction( this after [0s, 1h] $engineStart ) )

  then

insert ( new NoTransactions() );

System.out.println("no transactions for an hour since engine 
started");

end

rule "***notrx_after_trx***"

  when

EngineStart()

not( NoTransactions() )

$transaction : Transaction()

not( Transaction( this != $transaction, this after [0s, 1h] 
$transaction ) )

  then

insert( new NoTransactions() );

System.out.println("no transactions for an hour since last 
transaction ");

End

· First rule inserts an Event when rule engine starts

· Second rule detects absence of transactions since engine started

· Third rule detects absence of transactions since last transaction

 

The testcase is simple (using pseudoclock):

· 00h00m: rule engine start

· 00h30m: insert a transaction

· 01h01m: notification of absence of transactions since engine started 
(not the desired behavior)

 

I've attached the logs and I can't understand how an Activation is cancelled 
and executed afterwards (without any creation).

 

Thanks for the time spent to read this email! J 

 

 



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  





 

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


[rules-users] Activation doubt

2010-05-13 Thread Makewise - Vitor Rui Mendonça
Hi folks!

 

I'm having some trouble to understand activations.

My system receives transactions and I want to detect periods of time without 
transactions. If I don't have transactions for an hour, I want to sound an 
alarm.

 

I've wrote the following rules just to see how Drools works (I've tried sliding 
windows also but without success):

declare NoTransactions

  @role( event )

  timestamp: long

end

declare EngineStart

  @role( event )

  timestamp: long

end

declare Transaction

  @role( event )

  @expires( 1h )

end

rule "***start***"

  when

not( EngineStart() ) 

  then

insert( new EngineStart() );

System.out.println("engine started");

end

rule "***notrx_after_start***"

  when

$engineStart : EngineStart()

not( NoTransactions() )

not(Transaction( this after [0s, 1h] $engineStart ) )

  then

insert ( new NoTransactions() );

System.out.println("no transactions for an hour since engine 
started");

end

rule "***notrx_after_trx***"

  when

EngineStart()

not( NoTransactions() )

$transaction : Transaction()

not( Transaction( this != $transaction, this after [0s, 1h] 
$transaction ) )

  then

insert( new NoTransactions() );

System.out.println("no transactions for an hour since last 
transaction ");

End

· First rule inserts an Event when rule engine starts

· Second rule detects absence of transactions since engine started

· Third rule detects absence of transactions since last transaction

 

The testcase is simple (using pseudoclock):

· 00h00m: rule engine start

· 00h30m: insert a transaction

· 01h01m: notification of absence of transactions since engine started 
(not the desired behavior)

 

I've attached the logs and I can't understand how an Activation is cancelled 
and executed afterwards (without any creation).

 

Thanks for the time spent to read this email! J 

 

 

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro   

 



 

<><>

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


Re: [rules-users] Junit, PseudoClock and NPE

2010-03-23 Thread Makewise - Vitor Rui Mendonça
Edson, 

 

First of all, thanks for your quick reply!

 

I've submitted a new issue on Jira. Here's the link:

https://jira.jboss.org/jira/browse/JBRULES-2457

 

If anything else is needed please, let me know.

 

Thanks, once again J

 

Best regards,

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  

 



 

 

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: segunda-feira, 22 de Março de 2010 18:06
To: Rules Users List
Subject: Re: [rules-users] Junit, PseudoClock and NPE

 


 Hmmm, strange... would you be able to share your junit test? If so, could 
you please open a JIRA and attach the test? 

 Thanks,
Edson

2010/3/22 Makewise - Vitor Rui Mendonça 

Hi folks!

 

First time in this mailing-list, with very little experience in Drools (Fusion, 
regarding CEP).

I hope that someone could help me out J

 

I've being investigating about this issue and I'm not getting any answer.

 

Here's the problem:

I've got a DRL file with a simple rule:

rule ""

   when

 $offline : Event( code == "101", $offlineLane : lane ) from 
entry-point "incoming"

 not ( $online : Event(code == "102", lane == $offlineLane, this 
after [0s,3m] $offline ) from entry-point "incoming" )

   then

 // some code here  

end

 

What I want is: when there's an offline for more than 3 minutes *without* any 
online event (meanwhile), that execute the rule.

 

I've got JUnits, with Drools configured with STREAM mode and PSEUDO clock.

 

All is good in JUnit world except in this testcase:

· Insert an offline event (workingMemoryEntryPoint.insert( offlineEvent 
);)

· Clock advances 2m50s (clock.advanceTime(2,TimeUnit.MINUTES 
);clock.advanceTime(50, TimeUnit.SECONDS );)

· Insert an online event (workingMemoryEntryPoint.insert( onlineEvent 
);)

· Clock advances 0m15s (clock.advanceTime(15,TimeUnit.SECONDS );)

· Assertion error: the rule runs when it shouldn't (online event 
cancels offline event).

 

I've got no clue about this but I have some more interesting info:

· When clock advances 0m15s, there's an NPE on a LinkedList:
java.lang.NullPointerException

   at org.drools.util.LinkedList.remove(LinkedList.java:113)

   at org.drools.common.Scheduler$DuractionJob.execute(Scheduler.java:71)

   at 
org.drools.time.impl.PseudoClockScheduler$ScheduledJob.call(PseudoClockScheduler.java:219)

   at 
org.drools.time.impl.PseudoClockScheduler.runCallBacks(PseudoClockScheduler.java:168)

   at 
org.drools.time.impl.PseudoClockScheduler.advanceTime(PseudoClockScheduler.java:130)

· I haven't any code/rule that retracts events (I shouldn't have it for 
this case, right?)

· I've tried Drools 5.0.1 and 5.1.0.M1, with the same results

· The issue causing NPE, I've found an old issue regarding Drools 3.0.4 
and the bug was corrected in 3.0.5 
(https://jira.jboss.org/jira/browse/JBRULES-455)

· I think that someone wrote about this error (in Drools 5) but I don't 
have the link to it.

 

Thanks In Advance!

 

Best regards,

 



Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt
Uma empresa: Grupo Sousa Pedro <http://www.sousapedro.com>  





 

 


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




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com

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


[rules-users] Junit, PseudoClock and NPE

2010-03-22 Thread Makewise - Vitor Rui Mendonça
Hi folks!

 

First time in this mailing-list, with very little experience in Drools (Fusion, 
regarding CEP).

I hope that someone could help me out J

 

I've being investigating about this issue and I'm not getting any answer.

 

Here's the problem:

I've got a DRL file with a simple rule:

rule ""

   when

 $offline : Event( code == "101", $offlineLane : lane ) from 
entry-point "incoming"

 not ( $online : Event(code == "102", lane == $offlineLane, this 
after [0s,3m] $offline ) from entry-point "incoming" )

   then

 // some code here  

end

 

What I want is: when there's an offline for more than 3 minutes *without* any 
online event (meanwhile), that execute the rule.

 

I've got JUnits, with Drools configured with STREAM mode and PSEUDO clock.

 

All is good in JUnit world except in this testcase:

· Insert an offline event (workingMemoryEntryPoint.insert( offlineEvent 
);)

· Clock advances 2m50s (clock.advanceTime(2,TimeUnit.MINUTES 
);clock.advanceTime(50, TimeUnit.SECONDS );)

· Insert an online event (workingMemoryEntryPoint.insert( onlineEvent 
);)

· Clock advances 0m15s (clock.advanceTime(15,TimeUnit.SECONDS );)

· Assertion error: the rule runs when it shouldn't (online event 
cancels offline event).

 

I've got no clue about this but I have some more interesting info:

· When clock advances 0m15s, there's an NPE on a LinkedList:
java.lang.NullPointerException

   at org.drools.util.LinkedList.remove(LinkedList.java:113)

   at org.drools.common.Scheduler$DuractionJob.execute(Scheduler.java:71)

   at 
org.drools.time.impl.PseudoClockScheduler$ScheduledJob.call(PseudoClockScheduler.java:219)

   at 
org.drools.time.impl.PseudoClockScheduler.runCallBacks(PseudoClockScheduler.java:168)

   at 
org.drools.time.impl.PseudoClockScheduler.advanceTime(PseudoClockScheduler.java:130)

· I haven't any code/rule that retracts events (I shouldn't have it for 
this case, right?)

· I've tried Drools 5.0.1 and 5.1.0.M1, with the same results

· The issue causing NPE, I've found an old issue regarding Drools 3.0.4 
and the bug was corrected in 3.0.5 
(https://jira.jboss.org/jira/browse/JBRULES-455)

· I think that someone wrote about this error (in Drools 5) but I don't 
have the link to it.

 

Thanks In Advance!

 

Best regards,

 

 

Vítor Mendonça Moreira
Analista / Programador
Direcção de Investigação e Desenvolvimento

Rua Dr. Francisco Sá Carneiro, nº. 4 r/c esq.
2500 - 206 - Caldas da Rainha
Tel: (+351) 262 832 196
Fax: (+351) 262 186 455
Web: www.makewise.pt  
Uma empresa: Grupo Sousa Pedro   

 



 

 

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