[rules-users] Agenda events in a Stateless session

David Boaz davidb at dbmotion.com
Fri Mar 6 01:24:34 EST 2009


Your answer refered to Statefull session. My question was regarding a
stateless session, that do not extend WorkingMemory.
Currently, I did an ugly work-around. The Activation returns a
Collection<FactHandle>, and I noticed that in runtime, the FactHandle is
instanceof InternalFactHandle, that do have a getObject(). So, My code looks
like:
for(FactHandle handle:activation.getFactHandles()){
  assert(handle instanceof InternalFactHandle);
  Object o=((InternalFactHandle)handle).getObject();
  ...
}
Im looking for the correct way to implement this functionality. 
Thanks, David


Mark Proctor wrote:
> 
> David Boaz wrote:
>> Thanks Mark,
>>
>> The post bellow doesn't deal with the event listener registration.
>> Assuming
>> the registration was solved, now I have another issue. How to retrieve
>> the
>> Facts given Fact-handles? In a stateless session, I have no access to the
>> working memory.
>>   
> If you are using StatefulKnowledgeSession. Then the Activation has
>     Collection< ? extends FactHandle> getFactHandles();
> 
> And the KnowledgeRuntime is always available, which extends the 
> WorkingMemory.
> 
> Mkar
>> David
>>
>>
>> Mark Proctor wrote:
>>   
>>> David Boaz wrote:
>>>     
>>>> Hi all,
>>>>
>>>> Im trying to listen to the events fired during the evaluation of a
>>>> stateless
>>>> session. I implemented org.drools.event.rule.AgendaEventListener. The
>>>> events
>>>> fire as expected. From the event I can extract the Activation, the Rule
>>>> and
>>>> the list of FactHandles. Now, from each FactHandle I want to retrieve
>>>> the
>>>> associated fact (Object). For that, I need a WorkingMemory. But the WM
>>>> doesn't participate in the event signature. In addition, since Im using
>>>> a
>>>> stateless session, the working memory does not exist until I execute()
>>>> method.
>>>>
>>>> Can you please help?
>>>>   
>>>>       
>>> The event listeners don't work in the last release, this is fixed in 
>>> trunk, please give it a try in a snapshot:
>>> https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/
>>>     
>>>> Thanks, David
>>>>   
>>>>       
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>>     
>>
>>   
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Agenda-events-in-a-Stateless-session-tp22332020p22366837.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list