Re: [rules-users] please provide a rule for events timeout cases

2012-04-24 Thread skatta1986
thanks for the reply its giving expected results

--
View this message in context: 
http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3935376.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] please provide a rule for events timeout cases

2012-04-24 Thread Vincent LEGENDRE
and thanks for providing feedback !

- Mail original -
De: skatta1986 shivaprasad_...@yahoo.co.in
À: rules-users@lists.jboss.org
Envoyé: Mardi 24 Avril 2012 16:08:02
Objet: Re: [rules-users] please provide a rule for events timeout cases

thanks for the reply its giving expected results

--
View this message in context: 
http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3935376.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
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] please provide a rule for events timeout cases

2012-04-20 Thread Vincent LEGENDRE

 And make sure to use '==' when testing for equality!

Oh yes of course !! 
Did not noticed ...
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] please provide a rule for events timeout cases

2012-04-19 Thread skatta1986
Hi,

Now time out is working fine. 

But facing issues for correlating success and failure events which doesnot
have unique id. I want to correlate an event request followed by its
immediate event response.

Ex: Consider the events in below order
EventRecord( type=EventRequest, user=katta ) 
EventRecord( type=EventResponseFailure, user=katta ) 

EventRecord( type=EventRequest, user=katta ) 
EventRecord( type=EventResponseSuccess, user=katta ) 

Rules: 

rule event_success_case 
when 
   $req : EventRecord( type=EventRequest, user=katta ) 
   and EventRecord( type=EventResponseSuccess, user=katta,  this after[0s,
10s] $req ) 
then 
  System.out.println(Success case for user  + $req.getUser());
   retract($req);
end

rule event_failure_case 
when 
   $req : EventRecord( type=EventRequest, user=katta ) 
   and EventRecord( type=EventResponseFailure, user=katta,  this after[0s,
10s] $req ) 
then 
  System.out.println(Failed case for user  + $req.getUser());
  retract($req);
end

In the above example I don't have any unique identity to correlate request
and response. I need to correlate only based on events order. 


In the above example events order is EventRequest -- EventResponseFailure
and then EventRequest -- EventResponseSuccess. So my expected output is:
Failed case for user katta
Success case for user katta

But I am getting below response:
Success case for user katta
Success case for user katta

First EventRequest and second EventRequest are correlating with second
response EventResponseSuccess as this response is within 0 to 10sec for both
events. 

Note: I am getting expected result only when I send few events. If I insert
around 50 events at time into Working Memory, I face this kind of unexpected
result.

I need to work on live trafic, where I receive hurends of messages per
second.



--
View this message in context: 
http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3922235.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] please provide a rule for events timeout cases

2012-04-19 Thread Wolfgang Laun
Immediate response is one way of saying that there is no other
response between a request and a response for one user. Simply add
this condition, testing for both kinds of response.

-W

On 19/04/2012, skatta1986 shivaprasad_...@yahoo.co.in wrote:
 Hi,

 Now time out is working fine.

 But facing issues for correlating success and failure events which doesnot
 have unique id. I want to correlate an event request followed by its
 immediate event response.

 Ex: Consider the events in below order
 EventRecord( type=EventRequest, user=katta )
 EventRecord( type=EventResponseFailure, user=katta )

 EventRecord( type=EventRequest, user=katta )
 EventRecord( type=EventResponseSuccess, user=katta )

 Rules:

 rule event_success_case
 when
$req : EventRecord( type=EventRequest, user=katta )
and EventRecord( type=EventResponseSuccess, user=katta,  this after[0s,
 10s] $req )
 then
   System.out.println(Success case for user  + $req.getUser());
retract($req);
 end

 rule event_failure_case
 when
$req : EventRecord( type=EventRequest, user=katta )
and EventRecord( type=EventResponseFailure, user=katta,  this after[0s,
 10s] $req )
 then
   System.out.println(Failed case for user  + $req.getUser());
   retract($req);
 end

 In the above example I don't have any unique identity to correlate request
 and response. I need to correlate only based on events order.


 In the above example events order is EventRequest -- EventResponseFailure
 and then EventRequest -- EventResponseSuccess. So my expected output is:
 Failed case for user katta
 Success case for user katta

 But I am getting below response:
 Success case for user katta
 Success case for user katta

 First EventRequest and second EventRequest are correlating with second
 response EventResponseSuccess as this response is within 0 to 10sec for both
 events.

 Note: I am getting expected result only when I send few events. If I insert
 around 50 events at time into Working Memory, I face this kind of unexpected
 result.

 I need to work on live trafic, where I receive hurends of messages per
 second.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3922235.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 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] please provide a rule for events timeout cases

2012-04-19 Thread skatta1986
Could you please help out me in this...

modified rules: But it is giving thread exception at runtime

rule event_success_case 
 when 
$req : EventRecord( type=EventRequest, user=katta ) 
and $resp : EventRecord( type=EventResponseSuccess, user=katta,  this
after[0s, 10s] $req ) 
and ( not (EventRecord( type=EventResponseSuccess, user=katta,  this
after[0s, 10s] $req , this before[0s, 10s] $resp)))
#and ( not (EventRecord( type=EventResponseSuccess, user=katta, $req
overlaps this, this overlaps $resp) ))
 then 
   System.out.println(Success case for user  + $req.getUser()); 
retract($req); 
 end 
 
rule event_failure_case 
 when 
$req : EventRecord( type=EventRequest, user=katta ) 
and EventRecord( type=EventResponseFailure, user=katta,  this
after[0s, 10s] $req ) 
and ( not (EventRecord( type=EventResponseFailure, user=katta,  this
after[0s, 10s] $req , this before[0s, 10s] $resp)))
#and ( not (EventRecord( type=EventResponseFailure, user=katta, $req
overlaps this, this overlaps $resp) ))
 then 
   System.out.println(Failed case for user  + $req.getUser()); 
   retract($req); 
 end 

--
View this message in context: 
http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3923831.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] please provide a rule for events timeout cases

2012-04-19 Thread Vincent LEGENDRE
without the error trace, hard to say why it crashes ...

But your rules can be simplified/clarified :
   - and to connect conditions is not needed
   - in your first 'not' condition, which you add to test that no other event 
takes place between the two objects matched in previous patterns, you should 
test the two response types, as you don't want *any* response ...
   - again in your first 'not' condition, the after/before should not be in a 
interval. Why not using after/before only ? For timeout ? Should be a third 
rule to me ... and should add a rule to handle response coming after the 
timeout too.
   - I cant see the utility of you second 'not' pattern (may be because of my 
previous remarks)

Another question : why don't you retract the response too ? Is it because you 
want to keep them ?
To me it is better to retract it, especially if it takes place between another 
initial EventRequest and its response. at least mark the response as treated 
and ignore the treated responses in your conditions
 

So, your rules will become 2 groups of rules : first group to handle the 
response that correspond to a request, second group to handle the timeout cases 
:

rule event_success_case 
 when 
$req : EventRecord( type=EventRequest, $user : user ) 
$resp : EventRecord( type=EventResponseSuccess, user=$user,  this after 
$req ) 
not (EventRecord( type=EventResponseSuccess || EventResponseFailure, 
user=$user,  
  this != $resp, this after $req , this before $resp)))
# 'this != $resp' is not mandatory as you test after/before (which are 
strict), but it does not harm ...
 then 
System.out.println(Success case for user  + $req.getUser()); 
retract($req); 
retract($resp);  
end 
 
rule event_failure_case : same but testing the other status


rule event_timeout_case
 when 
$req : EventRecord( type=EventRequest, $user : user ) 
not (EventRecord( type=EventResponseSuccess || EventResponseFailure, 
user=$user,  
  this after[0,10s] $req))) // assuming 10s for timeout
 then 
System.out.println(Timeout case for user  + $req.getUser()); 
retract($req); 
end 



rule event_response_after_timeout_case
 when 
$resp: EventRecord( type=EventResponseSuccess || EventResponseFailure, 
$user : user ) 
not (EventRecord( type=EventRequest, user=$user,  
  this before $resp)))
 then 
System.out.println(Response coming after timeout case for user  + 
$req.getUser()); 
retract($resp); 
end 


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


Re: [rules-users] please provide a rule for events timeout cases

2012-04-19 Thread Wolfgang Laun
With this kind of scenario it helps a lot if you retract a matching
pair (R+S, R+F). (If you need the information for further processing,
create another fact.)

And make sure to use '==' when testing for equality!

rule request_success
when
 $req : EventRecord( type == EventRequest, $user: user)
 $resp : EventRecord( type == EventResponseSuccess, user==$user,
this after[0s.10s] $req )
 not EventRecord( type == EventResponseSuccess || == EventResponseFailure,
  user == $user, this before $resp )
then
 // success
 retract( $req );
 retract( $resp );
end

-W


On 19/04/2012, skatta1986 shivaprasad_...@yahoo.co.in wrote:
 Could you please help out me in this...

 modified rules: But it is giving thread exception at runtime

 rule event_success_case
  when
 $req : EventRecord( type=EventRequest, user=katta )
 and $resp : EventRecord( type=EventResponseSuccess, user=katta,  this
 after[0s, 10s] $req )
 and ( not (EventRecord( type=EventResponseSuccess, user=katta,  this
 after[0s, 10s] $req , this before[0s, 10s] $resp)))
 #and ( not (EventRecord( type=EventResponseSuccess, user=katta, $req
 overlaps this, this overlaps $resp) ))
  then
System.out.println(Success case for user  + $req.getUser());
 retract($req);
  end

 rule event_failure_case
  when
 $req : EventRecord( type=EventRequest, user=katta )
 and EventRecord( type=EventResponseFailure, user=katta,  this
 after[0s, 10s] $req )
 and ( not (EventRecord( type=EventResponseFailure, user=katta,  this
 after[0s, 10s] $req , this before[0s, 10s] $resp)))
 #and ( not (EventRecord( type=EventResponseFailure, user=katta, $req
 overlaps this, this overlaps $resp) ))
  then
System.out.println(Failed case for user  + $req.getUser());
retract($req);
  end

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3923831.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 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] please provide a rule for events timeout cases

2012-04-16 Thread skatta1986
Hi, Thanks for the response..

This is working fine.. But I have a query on the rule:
rule no_response 
   timer( int: 10s ) 
when 
   EventRecord( type=EventRequest, id=1 ) 
   not EventRecord( type=EventResponse, id=1 ) 

In general timer means executing a thread for every specified time period
interval. But in our case, one time would be enough for an event. In the
above rule my query is - after timeout case (i.e., firstime 10 seconds from
the EventRequest), timer thread will be closed or will it be still running?

Second Query is:

Consider the below Success rule:
rule event_success_case 
 when 
   EventRecord( type=EventRequest, id=1 ) 
   and EventRecord( type=EventResponse, id=1 ) 

With no_response rule, for every EventRequest there is a timer thread
running for every 10Sec. Second rule event_success_case looks for its
EventResponse. Suppose with in 10 seconds there is a response then
event_success_case rule is run. Now I would like to close the timer thread
because it uses my system memory. Please let me know if this is possible.


--
View this message in context: 
http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3914382.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] please provide a rule for events timeout cases

2012-04-13 Thread skatta1986
Hi,

I would like to write a rule for events timeout case. 

Consider the events EventRecord(type=EventRequest, id=1) and
EventRecord(type=EventResponse, id=1).
I have written rules (in .drl file) for correlting the event request with
event response. 

Now I would like to write timeout case. Suppose
EventRecord(type=EventRequest, id=2) is not followed by its response. If we
doesn't recieve response within 10 seconds, then it is considered as timeout
case.
I tried to use timers but it doen't work as it is not allowing me write
inside when (LHS) pattern. 

Is there any other way to find timeout cases?



--
View this message in context: 
http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3907955.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] please provide a rule for events timeout cases

2012-04-13 Thread Esteban Aliverti
First question: are you using Drools Fusion?
If yes, did you try with something like this?:

EventRecord(type=EventRequest, id=1)
not EventRecord(type=EventResponse, id=1, this after [1s,10s]).

I'm using a 10s timeout here.

Best Regards,



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


On Fri, Apr 13, 2012 at 3:03 PM, skatta1986 shivaprasad_...@yahoo.co.inwrote:

 Hi,

 I would like to write a rule for events timeout case.

 Consider the events EventRecord(type=EventRequest, id=1) and
 EventRecord(type=EventResponse, id=1).
 I have written rules (in .drl file) for correlting the event request with
 event response.

 Now I would like to write timeout case. Suppose
 EventRecord(type=EventRequest, id=2) is not followed by its response. If we
 doesn't recieve response within 10 seconds, then it is considered as
 timeout
 case.
 I tried to use timers but it doen't work as it is not allowing me write
 inside when (LHS) pattern.

 Is there any other way to find timeout cases?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3907955.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 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