[rules-users] Where to cache KnowledgeAgent

Laird Nelson ljnelson at gmail.com
Fri Nov 8 11:51:17 EST 2013


On Fri, Nov 8, 2013 at 8:37 AM, darrell.pittman
<darrell at darrellpittman.ca>wrote:

> Hello,
>
> I am new to Drools a starting a new Java EE 6 application that will use
> drools.  We are not using Guvnor.  I am wondering what is the suggested way
> of creating the knowledge agent and where to cache it.  EJB's shouldn't
> read
> from the file system so I guess a Singleton EJB is out as far as loading
> the
> knowledgebase goes.  Should I load knowledgebase in a
> ServletContextListener
> and store it in the ServletContext and pass it into my EJB's?  What is the
> recommend practice?
>

I faced the same problem.  There is surprisingly little information on how
people do this.  The next issue you're going to face is when or if to
serialize sessions (recreating them on every request is too expensive).
 Then you're probably going to run into issues with how to get the
KnowledgeBase if your KnowledgeAgent discovers a new one.

The "correct" way (Java EE-approved) to get the KnowledgeAgent working is
to use it via a resource adapter, because KnowledgeAgent uses the
filesystem and threads, both of which are no-nos in a Java EE environment.
 It just so happens I wrote one a long time ago:
https://github.com/ljnelson/drools-jca  I can't vouch for whether it is
entirely correct (JCA is a black art) but it worked for me.

Do let us know how you end up proceeding with your architecture.

Best,
Laird

-- 
http://about.me/lairdnelson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20131108/22093063/attachment.html 


More information about the rules-users mailing list