0 Replies Latest reply: Jan 29, 2012 1:35 PM by Jonathan Fields RSS

observing multiple repositories on the same app

Jonathan Fields Novice

Hi All,

 

I have a Modeshape 2.7/JBoss AS 6 kit application. My application has multiple repositories. I need to observe all repositories for certain events, and forward that information onto JMS.

 

My current appoach uses a JBoss @Service bean (equivalent to a @Singleton) that during app startup, loops through all of the repositories, calling ObservationManager.addEventListener(eventListener, ...).  The eventListener is a local EJB reference to a stateful session bean that implements javax.jcr.observation.EventListener. The Session is not used for anything else until the application is shutdown, and Session.logout() is called.

 

The reason that it is a stateful bean is that the repository name is not passed into the EventListener.onEvent(EventIterator) call. Thus, to open a new Session in EventListener.onEvent() to process the event, the repository name needs to be stored in the stateful bean, so that the Repository can be obtained, and then the Session from that....

 

Since stateful beans can only be invoked from one thread, my question is then: is it possible to have concurrent invocations to EventListener.onEvent(), which will break the stateful bean? Or are they synchronized?

 

If they can be concurrent, does does anybody have any suggestions how to observe events in an EJB environment?  Or am I missing something completely obvious or is there some different approach?

 

Thanks!