Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] Bug 332581 - SessionBroker session event issues to consider and resolve when implementing JPA Session Broker
The patch is ready for review.

The patch fixes exception and session events handling according to the
following rules.

Exception handling:
1) if session has a parent then when the session is created exception handler
is copied from the parent;
2) if session has a broker (member of SessionBroker) then broker's handler is
used if session's handle either does not exist or has failed (has thrown

Session Events handling:
1) when session is created if it has a parent then session events handler is
cloned from the parent;
2) when DatabaseSession/ServerSession is registered with SessionBroker all the
listeners from the SessionBroker are added to the
3) when a listener is added/removed to/from SessionBroker it is also
added/removed to/from all member sessions;
4) adding/removing listener to/from EventSessionManager could be done
concurrently - it's thread safe.

What do these rules mean for SessionBroker users?
1) If exception or event originates in a UnitOfWork then it will be handled by
its parent SessionBroker, NOT by member sessions;
2.1) If exception originates on a member session, then it's handled by this
member session only, if there is no handler or handler fails then the exception
is handled by the broker.
2.2) If event originates on a member session then it is passed to the listeners assigned to this member session AND to the listeners copied from broker. Note
that the session passed with the event is always the member session.
2.3) The most straightforward strategy is to register all SessionEventListeners with SessionBroker. That guarantees that the event will be always called and it will be easy to handle because the member session or unit of work on which the
event originated is passed with the event.
3) Thread safety of EventSessionManager is essential when adding a new listener
to a session while it is concurrently used (adding a listener to connected
ServerSession or ServerSession SessionBroker).

Tests are coming soon.

Back to the top