[rules-users] Stateless session dis-associating listeners after first execute call. Bug or a feature?

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

[rules-users] Stateless session dis-associating listeners after first execute call. Bug or a feature?

michalbali
Hello,

I am using a stateless session. First I add an agenda event listener. When I first call session.execute(Itelable) all works as expected. However when I call it the second time (without adding the listener again) the listener does not seem to be called at all.
However note that when I call session.getAgendaEventListeners() the event listener is always there.
IMHO I am guessing that the 'dispose' method that is called behind the scenes possibly dis-associates the event listener.
I've tested this with 5.5.Final. BTW This worked fine with Drools 5.0. I haven't checked later versions.
I wonder is this a bug or a feature?

Isolated test case is attached.

Thank you.
Best regards,
Michal

_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users

StatelessSessionTest.java (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Stateless session dis-associating listeners after first execute call. Bug or a feature?

laune
>From the Javadoc of dispose() (quote: "Releases all [...] resources,
setting up the session for garbage collection") I derived the notion
that dispose is the last goodbye to any session object, so that it
can't be used any more. Just removing all facts and thereby all
activations based on the presences of facts and recreating all
activations merely based on "eval(true)" would be more like a
description for returning a session to its initial state, which is
what you need, in general, for re-using any session.

Does the session produce anything at all during the second execute()?

If "dispose()" really is the end, another execute() should result in
an exception; if there is no exception, it should function correctly -
tertium non datur ;-)

-W

On 25/12/2012, Michal Bali <[hidden email]> wrote:

> Hello,
>
> I am using a stateless session. First I add an agenda event listener. When
> I first call session.execute(Itelable) all works as expected. However when
> I call it the second time (without adding the listener again) the listener
> does not seem to be called at all.
> However note that when I call session.getAgendaEventListeners() the event
> listener is always there.
> IMHO I am guessing that the 'dispose' method that is called behind the
> scenes possibly dis-associates the event listener.
> I've tested this with 5.5.Final. BTW This worked fine with Drools 5.0. I
> haven't checked later versions.
> I wonder is this a bug or a feature?
>
> Isolated test case is attached.
>
> Thank you.
> Best regards,
> Michal
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Stateless session dis-associating listeners after first execute call. Bug or a feature?

michalbali
Hi Wolfgang,

I am not calling dispose() as it is not possible to dispose a stateless session. I've just noticed that it is called automatically by Drools internal code (when calling StatelessKnowledgeSession.execute(Iterable) method).

Thank you for responding.
Best Regards,
Michal


On Wed, Dec 26, 2012 at 9:45 AM, Wolfgang Laun <[hidden email]> wrote:
tertium non datur


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

Re: [rules-users] Stateless session dis-associating listeners after first execute call. Bug or a feature?

laune
On 04/01/2013, Michal Bali <[hidden email]> wrote:
> Hi Wolfgang,
>
> I am not calling dispose() as it is not possible to dispose a stateless
> session.

Which I didn't suggest you'd do.

> I've just noticed that it is called automatically by Drools
> internal code (when calling StatelessKnowledgeSession.execute(Iterable)
> method).

And I tried to point out its consequences and the lack of
clarification in the Drools docs whether this is the end of life for a
StatelessKnowledgeSession.

-W

>
> Thank you for responding.
> Best Regards,
> Michal
>
>
> On Wed, Dec 26, 2012 at 9:45 AM, Wolfgang Laun
> <[hidden email]>wrote:
>
>> tertium non datur
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|

Re: [rules-users] Stateless session dis-associating listeners after first execute call. Bug or a feature?

Mark Proctor
each execute creates a new stateful session. All the listers are added to that after it's created, see newWorkingMemory:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java

Mark
On 4 Jan 2013, at 16:20, Wolfgang Laun <[hidden email]> wrote:

> On 04/01/2013, Michal Bali <[hidden email]> wrote:
>> Hi Wolfgang,
>>
>> I am not calling dispose() as it is not possible to dispose a stateless
>> session.
>
> Which I didn't suggest you'd do.
>
>> I've just noticed that it is called automatically by Drools
>> internal code (when calling StatelessKnowledgeSession.execute(Iterable)
>> method).
>
> And I tried to point out its consequences and the lack of
> clarification in the Drools docs whether this is the end of life for a
> StatelessKnowledgeSession.
>
> -W
>
>>
>> Thank you for responding.
>> Best Regards,
>> Michal
>>
>>
>> On Wed, Dec 26, 2012 at 9:45 AM, Wolfgang Laun
>> <[hidden email]>wrote:
>>
>>> tertium non datur
>>
> _______________________________________________
> 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: [rules-users] Stateless session dis-associating listeners after first execute call. Bug or a feature?

michalbali
Thanks Mark, Wolfgang,

I had a look at the source code of StatelessKnowledgeSessionImpl.java (from
https://github.com/droolsjbpm/drools/blob/5.5.0.Final/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java )
It seems that when execute(..) is being called for the first time, the event listeners are being added to this.agendaEventSupport, see line number 136. However when the dispose() method is being called internally by Drools this agendaEventSupport collection is cleared. Then upon further executions (calls to the execute(..) method) the event listeners are no longer added to this.agendaEventSupport and hence they are not being triggered
I've created JBRULES-3711.

Thank you.
Best regards,
Michal

On Sat, Jan 5, 2013 at 5:20 AM, Mark Proctor <[hidden email]> wrote:
each execute creates a new stateful session. All the listers are added to that after it's created, see newWorkingMemory:
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/impl/StatelessKnowledgeSessionImpl.java

Mark
On 4 Jan 2013, at 16:20, Wolfgang Laun <[hidden email]> wrote:

> On 04/01/2013, Michal Bali <[hidden email]> wrote:
>> Hi Wolfgang,
>>
>> I am not calling dispose() as it is not possible to dispose a stateless
>> session.
>
> Which I didn't suggest you'd do.
>
>> I've just noticed that it is called automatically by Drools
>> internal code (when calling StatelessKnowledgeSession.execute(Iterable)
>> method).
>
> And I tried to point out its consequences and the lack of
> clarification in the Drools docs whether this is the end of life for a
> StatelessKnowledgeSession.
>
> -W
>
>>
>> Thank you for responding.
>> Best Regards,
>> Michal
>>
>>
>> On Wed, Dec 26, 2012 at 9:45 AM, Wolfgang Laun
>> <[hidden email]>wrote:
>>
>>> tertium non datur
>>
> _______________________________________________
> 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


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users