Error Inserting events into drools fusion stream

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Error Inserting events into drools fusion stream

Ayush
Hi All,

I'm trying to implement drools fusion into my app. The scenario of my app is as follows:
- Facts will be received continuosly.
- On receving fact I'm generating a new event and adding it into a new working memory entry point stream. Also I'm adding facts into session coz I'll be updating them.
- I need to apply rules on continuous stream of events.
- I've not used any camel + spring or pipeline. Are these mandatory to use?

For 1st fact everything works fine but when I receive 2nd fact I'm getting Now when I'm trying to get entry point on receive of 2nd alarm I'm getting org.drools.RuntimeDroolsException: Unexpected exception executing action org.drools.reteoo.PropagationQueuingNode$PropagateAction@9ff411  Caused by: java.util.concurrent.RejectedExecutionException.

On debug I found that the above exception is coming when I'm calling session.getWorkingMemoryEntryPoint("MyStream"); Can anyone please help me that how should I insert facts and events into working memory?

 I'd invested ample amount of time searching for this  but I'm empty handed. Guys please help this is very urgent for me. Thanks in anticipation
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

Pankaj Khattar
Hi,

I am facing the same problem, i have read somewhere that we can use the same session throughout the application but I'm unable to figure it how?

Also how can we insert events from my application into the same working memory entry-point?

Below is the code I'm using please let me know if this is the right way to do it

static StatefulKnowledgeSession session;

session  = knowledgeBase.newStatefulKnowledgeSession();
WorkingMemoryEntryPoint entryPoint = session.getWorkingMemoryEntryPoint("NotificationStream");
entryPoint.insert(new MyReceivedEvent());
session.fireAllRules();

I'm calling the above code every time a new event is received. Also in the finally block I'm calling session.dispose();

While inserting the 2nd event in entry-point I'm getting org.drools.RuntimeDroolsException: Unexpected exception executing action org.drools.reteoo.PropagationQueuingNode$PropagateAction@9ff411  Caused by: java.util.concurrent.RejectedExecutionException.

Can anyone please let me know the right way to do it?
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

laune
Normally a Fusion session is created once, possibly initialized with some static facts,
and then you use the entry point to insert events, call fireAllRules, and wait for the
next event to arrive from its source. Therefore, keep the session and the entry point
for repeated use by the last two statements.
-W

On 22 October 2010 06:08, Pankaj Khattar <[hidden email]> wrote:

Hi,

I am facing the same problem, i have read somewhere that we can use the same
session throughout the application but I'm unable to figure it how?

Also how can we insert events from my application into the same working
memory entry-point?

Below is the code I'm using please let me know if this is the right way to
do it

static StatefulKnowledgeSession session;

session  = knowledgeBase.newStatefulKnowledgeSession();
WorkingMemoryEntryPoint entryPoint =
session.getWorkingMemoryEntryPoint("NotificationStream");
entryPoint.insert(new MyReceivedEvent());
session.fireAllRules();

I'm calling the above code every time a new event is received. Also in the
finally block I'm calling session.dispose();

While inserting the 2nd event in entry-point I'm getting
org.drools.RuntimeDroolsException: Unexpected exception executing action
org.drools.reteoo.PropagationQueuingNode$PropagateAction@9ff411  Caused by:
java.util.concurrent.RejectedExecutionException.

Can anyone please let me know the right way to do it?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1750434.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

Ayush
Thanks for the reply.

Can you please elaborate on it?

Well we are facing issues keeping same session and entry point alive through out the application.

As each event will be received as a new thread in my application so when I'm calling the class which inserts into session and fire-all rules then it's also called as new thread and when called it again initializes the session. I tried to prevent it by not calling session.dispose() and making it static. For the 1st thread it works fine but for the second thread when I insert event into entry-point I get the exception due to concurrent modification.

How can I implement it so that the session and entry-point is initialized only once and every new event, which is a new thread, will be inserted into the same entry-point? Also I want that prevoius facts and events should be in drools memory because I'm working on previous alarms as well?
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

laune
This is more a Java question than a Drools specific problem.

You have several producers, running in threads, parallel or (more or less) one
after the other. You have one consumer, the thread running the single session.
Consuming consists of accepting the fact and inserting it into the session; then
fireAllRules must be called; then the Consumer is ready for the next fact.

Look into java.util.concurrent. One object implementing BlockingQueue<?>
is what you need for communication between producers and the consumer.
You'll have to figure out the details, depending on the runtime parameters
of your application, i.e., arrival frequency, average processing time by the
Engine, etc.

-W


On 22 October 2010 08:10, Ayush <[hidden email]> wrote:

Thanks for the reply.

Can you please elaborate on it?

Well we are facing issues keeping same session and entry point alive through
out the application.

As each event will be received as a new thread in my application so when I'm
calling the class which inserts into session and fire-all rules then it's
also called as new thread and when called it again initializes the session.
I tried to prevent it by not calling session.dispose() and making it static.
For the 1st thread it works fine but for the second thread when I insert
event into entry-point I get the exception due to concurrent modification.

How can I implement it so that the session and entry-point is initialized
only once and every new event, which is a new thread, will be inserted into
the same entry-point? Also I want that prevoius facts and events should be
in drools memory because I'm working on previous alarms as well?
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Error-Inserting-events-into-drools-fusion-stream-tp1746213p1750771.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

Ayush
Thank you for your reply.

I think I was heading into the wrong direction. Now when I've synchronized the function which is creating session, session is static and is only called once, and firing the rules it's working fine. I'm planning to use JMS wherein consumer will be syncronized. Is this the right way?

But I've following rule rule

"TwoAlertsFromSameSource"
        no-loop true
        dialect "mvel"
        when
                $RA : AlertReceivedEvent( severity == 2, $entityA : entity ) over window:time(60s) from entry-point NotificationStream
                $RB : AlertReceivedEvent( this != $RA, severity == 1, $entityB : entity ) over window:time(60s) from entry-point NotificationStream
                $alertB : X733Alert(this.entity == $entityB, correlationState != CorrelationStates.ROOT_CAUSE)
                $alertA : X733Alert(this.entity == $entityA, correlationState != CorrelationStates.SYMPATHETIC)
        then
                System.out.println("#### Running TwoAlertsFromSameSource... ####");
                modify($alertB) {
                        setCorrelationState("Main");
                }
               
                System.out.println("correlation state "+$alertB.getCorrelationState());

                modify($alertA) {
                        setCorrelationState("Lower");
                }
end

In above rules it's unable to modify $alertB. I'm working on it and hoping that this also comes out to be java problem.
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

Ayush
In reply to this post by laune
Thank you for your reply.

I think I was heading into the wrong direction. Now when I've synchronized the function which is creating session, session is static and is only called once, and firing the rules it's working fine. I'm planning to use JMS wherein consumer will be syncronized. Is this the right way?

But I've following rule rule

"TwoAlertsFromSameSource"
        no-loop true
        dialect "mvel"
        when
                $RA : AlertReceivedEvent( severity == 2, $entityA : entity ) over window:time(60s) from entry-point NotificationStream
                $RB : AlertReceivedEvent( this != $RA, severity == 1, $entityB : entity ) over window:time(60s) from entry-point NotificationStream
                $alertB : X733Alert(this.entity == $entityB, correlationState != CorrelationStates.ROOT_CAUSE)
                $alertA : X733Alert(this.entity == $entityA, correlationState != CorrelationStates.SYMPATHETIC)
        then
                System.out.println("#### Running TwoAlertsFromSameSource... ####");
                modify($alertB) {
                        setCorrelationState("Main");
                }
               
                System.out.println("correlation state "+$alertB.getCorrelationState());

                modify($alertA) {
                        setCorrelationState("Lower");
                }
end

In above rules it's unable to modify $alertB. I'm working on it and hoping that this also comes out to be java problem.
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

laune
In reply to this post by Ayush
On 22 October 2010 09:14, Ayush <[hidden email]> wrote:

Thank you for your reply.

I think I was heading into the wrong direction. Now when I've synchronized
the function which is creating session, session is static and is only called
once, and firing the rules it's working fine. I'm planning to use JMS
wherein consumer will be syncronized. Is this the right way?

Should be OK.
 

But I've following rule rule

"TwoAlertsFromSameSource"
       no-loop true
       dialect "mvel"
       when
               $RA : AlertReceivedEvent( severity == 2, $entityA : entity ) over
window:time(60s) from entry-point NotificationStream
               $RB : AlertReceivedEvent( this != $RA, severity == 1, $entityB : entity )
over window:time(60s) from entry-point NotificationStream
               $alertB : X733Alert(this.entity == $entityB, correlationState !=
CorrelationStates.ROOT_CAUSE)
               $alertA : X733Alert(this.entity == $entityA, correlationState !=
CorrelationStates.SYMPATHETIC)
       then
               System.out.println("#### Running TwoAlertsFromSameSource... ####");
               modify($alertB) {
                       setCorrelationState("Main");
               }

               System.out.println("correlation state "+$alertB.getCorrelationState());

               modify($alertA) {
                       setCorrelationState("Lower");
               }
end

In above rules it's unable to modify $alertB

This looks fine, and if $alertA is modified, $alertB will be, too -  unless s.th. else
is in error. One possibility is that $alertA and $alertB refer to the same fact and the
2nd modify ovwrites the 1st.
-W


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

Ayush
Thanks a lot Wolfgang for your prompt reply. I'm able to move forward now
xyz
Reply | Threaded
Open this post in threaded view
|

Re: Error Inserting events into drools fusion stream

xyz
How did you solve this issue.