[Seaside] Ressource management
mbany at cincom.com
Tue May 23 13:40:26 UTC 2006
> to seaside I'm certainly a beginner, and from this it is not
> clear to me what rules there are for proper ressource
> management. I had the problem with ODBC connections, which
> were catched by WASessions (I think). Only a "Cache clean"
> killed the ODBC instances.
> Where would be a good place to clean - up i.e. database connections ?
In one of my projects, we are using Seaside in VW for building a UI
for a service that is running on a mainframe. The communication between
the UI and the service is based upon socket connections which are
out of a pool. We have a mechanism for obtaining socket connections
from the pool and another one for releasing and cleaning them up. The
connections are obtained lazily as needed and released as early as
when no longer needed, to make sure that socket connections with the
mainframe are held as briefly as possible.
Although this is not database connections, these ideas may be reusable
in your case.
For robustness, we need to make sure that socket connections are
released in all situations, so we have subclassed WASession and
#responseForRequest: with something like this :
[response := super responseForRequest: aRequest]
ensure: [self releaseResourcesForRequest: aRequest
We are not using #unregistered, since we are not holding any socket
connection resource between HTTP requests.
For even more robustness (when something weird occurs while executing
the ensure block above), we also subclassed WAProcessMonitor and
#terminate with something like this:
| theProcess |
(theProcess := process) ifNotNil:
self releaseResourcesForProcess: theProcess].
The WAProcessMonitor object is instantiated in the #initialize method
of our WASession subclass
monitor := MyProcessMonitor new.
More information about the Seaside