Assuming I have the following rule:

global SomeClient client;

rule "Poll Values"
timer (int: 0s 1s)
when
    $data: Data() from client.getData();
then
    insert($data);
end

and that I'm just creating a session with just that rule, setting the global and calling fireAllRules(). And let's say that my session is running for 5 seconds.

My questions are:
1.- How many times is the rule going to be executed?
2.- How many times is  client.getData() going to be invoked? 

The test I have shows that the rule is executed 5 times, but client.getData() is only invoked for the first activation. The returned object is used in the subsequent activations. Is this the expected behavior?
As the rule name states, I'm expecting to get some (different) values from client every second. 
I understand that I'm doing 'strange' things since the rule doesn't use any real fact but I would like to understand why I'm experiencing the described behavior.  

Best Regards,


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Blog @ http://ilesteban.wordpress.com