0

I have a set of rules that fire each 15seconds.

As I want to unit-test these rules, I want to set dynamically this duration value. More, I want to put it in my app's configuration. This value might be used in more than 20 rules...).

How can I do this ? Is it possible ?

Here is my rule :

rule "my rule Name"
duration 15000
when
    //match something
then
    //do something
end 

I would like to have something like :

gobal String timeDuration;

rule "my rule Name"
duration timeDuration
when
    //match something
then
    //do something
end 

I tried : - putting a long global variable set from my unit test - putting a String global variable set from my unit test containing "15s" - Import a class containing a static field and put


import my.temp.package.RemoveThisUglyClass;
rule "my rule Name"
duration RemoveThisUglyClass.timeDuration
when
    //match something
then
    //do something
end 

Seems that there is no way to do it. A I right ? Any suggestion ?

Thanx !

user3738021
  • 103
  • 6

1 Answers1

2

The duration rule attribute is deprecated for quite some time. You can use timer:

rule "tock"
timer( expr: $d )
when
    A($d: duration )
then
    //...
end

This fires after the number of milliseconds in duration, but you can also use String fields containing times like "3s". See the documentation.

laune
  • 31,114
  • 3
  • 29
  • 42
  • Thanx your response helped me : I used a global variable containing my duration value and use it directly in the timer. – user3738021 Jun 16 '14 at 12:23