cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Durchholz, Joachim" <Joachim.Durchh...@hennig-fahrzeugteile.de>
Subject RE: Standalone app, Threads and Object contexts
Date Wed, 02 May 2012 09:11:48 GMT
> Unfortunately, I may have up to 200 simultaneous requests
> at the database.

Not a problem.

> I'm sure the database administrator won't like to see my
> app opening and closing connections to their database
> so I would prefer to open up a pool of connections and
> then share them among the incoming requests much like a
> web app.

Standalone apps tend to work by opening a single Connection
and using that for all requests.
The snag here is that connections will break sooner or later
(due to networking problems, server restarts, idle time, or
a multitude of other causes), so this needs a library that
recreates a broken connection on the fly.
Connection pooling libraries do that as a side effect. That
means that you use such a library, but not for the pooling
(no need to share connection across "requests", there is no
such thing in a J2SE application unless your design calls
for one due to other reasons) but for the side effect of
recreating connections as needed.

Since I'm still stuck with Hibernate, I can't advise very
well about how to best integrate a connection pooling
library and Cayenne.
I'd probably look up the Cayenne docs on connection pooling,
and just make sure that everything is configured explicitly
that the web container would do for you implicitly.

BTW I've been working on a J2SE application for the last
three years, and it's probably really a good idea to design
the application around "requests" or "transactions".
Transactions can fail due to transient errors, so you want
them restartable, which means you need to wrap them in
objects, and there you have your requests. (This pattern
also sucks greatly because it isn't easy to pass results
back to the caller. Essentially, you're doing the exactly
same web service architecture, except it's running inside a
single JVM.)

Mime
View raw message