Stateless Session Persistence / observer pattern

Discussions

EJB programming & troubleshooting: Stateless Session Persistence / observer pattern

  1. Stateless Session Persistence / observer pattern (3 messages)

    I have implemented an EJB state machine for monitoring business processes.. and need to send events to listeners (over RMI).

    I would like to use a stateless session bean as the event dispatcher but am not sure where to persist the list of listeners in the session bean?

    Normally I would use a singleton event manager, how do I do this inside the container?
  2. I have implemented something very similiar. I used
    a DB to store my event listeners. It worked just fine.
  3. Have you evaluated JMS.

    If you where to implement the dispatcher, one option you have is to presist the list of observers in the database.
  4. We used a combination of a Mediator and an Observer to implement this. The Mediator is a singleton to which interested Observers register. The source of the events simply notifies the Mediator which in turn does a call-back on all registered Observers/Listeners.
    In your case, just wrap the Mediator in a stateless session bean. The Mediator should be brought up when the application starts up - say you could have a startup servlet that creates an instance of the Mediator in the init() and maintains the reference releasing it only in the destroy().