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-bounces(a)lists.jboss.org [mailto:rules-users-bounces@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>