cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <johnth...@gmail.com>
Subject Re: Reconnecting automatically after DB downtime
Date Mon, 07 Mar 2016 22:38:18 GMT
Amazon elastic beanstalk!
On Mon, Mar 7, 2016 at 4:32 PM Lon Varscsak <lon.varscsak@gmail.com> wrote:

> Well, I actually have embedded Jetty in my application.  But I’m not sure
> how to manage creating instances/stoping/starting, etc.  In WebObjects we
> had a tool called Monitor which would allow you to do it all on the fly.
> :D
>
> -Lon
>
> On Mon, Mar 7, 2016 at 3:30 PM, Michael Gentry <mgentry@masslight.net>
> wrote:
>
> > http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html
> >
> > (sent too soon)
> >
> >
> > On Mon, Mar 7, 2016 at 5:30 PM, Michael Gentry <mgentry@masslight.net>
> > wrote:
> >
> > > Just embed Jetty in your application...
> > >
> > >
> > > On Mon, Mar 7, 2016 at 5:18 PM, Lon Varscsak <lon.varscsak@gmail.com>
> > > wrote:
> > >
> > >> OT: I’m planning to build jar not war…now I’m not sure how to deploy.
> :P
> > >>
> > >> -Lon
> > >>
> > >> On Mon, Mar 7, 2016 at 2:27 PM, Hugi Thordarson <hugi@karlmenn.is>
> > wrote:
> > >>
> > >> > >> It looks to me like this makes it much harder to deploy your
> > >> > application in
> > >> > >> development/test/etc type environments since your URL/etc
are in
> > the
> > >> > code.
> > >> >
> > >> > Yeah, I see what you mean. We use a homebuilt property system for
> that
> > >> > which returns configuration based on environment. It’s not JNDI
but
> > >> works :)
> > >> >
> > >> > > Unless you use Bootique, or your own property-based config
> > mechanism.
> > >> >
> > >> > Is bootique worth checking out? I’m just noticing it now for the
> first
> > >> > time and so happens I’m looking into a new basis for our web
> > >> services/APIs
> > >> > (current favorite being spark framework).
> > >> >
> > >> > > "Make jar, not war" :)
> > >> >
> > >> > Ha ha ha :)
> > >> >
> > >> > - hugi
> > >> >
> > >> >
> > >> > >
> > >> > >> On Mar 7, 2016, at 1:13 PM, Michael Gentry <
> mgentry@masslight.net>
> > >> > wrote:
> > >> > >>
> > >> > >> Hi Hugi,
> > >> > >>
> > >> > >> It looks to me like this makes it much harder to deploy your
> > >> > application in
> > >> > >> development/test/etc type environments since your URL/etc
are in
> > the
> > >> > code.
> > >> > >> The advantage of JNDI is you only reference a logical name
that
> is
> > >> > >> configured external to the WAR, making it much easier to
have one
> > >> build
> > >> > >> that can be deployed in different environments.  I took a
brief
> > >> glance
> > >> > at
> > >> > >> Hikari and don't think it includes JNDI natively.
> > >> > >>
> > >> > >> mrg
> > >> > >>
> > >> > >>
> > >> > >> On Mon, Mar 7, 2016 at 4:03 PM, Hugi Thordarson <
> hugi@karlmenn.is>
> > >> > wrote:
> > >> > >>
> > >> > >>> Well, that was easy! Up and running in production.
> > >> > >>>
> > >> > >>> HikariConfig config = new HikariConfig();
> > >> > >>> config.setJdbcUrl(
> > >> > >>>
> > >> >
> > >>
> >
> "jdbc:mysql://server:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&connectTimeout=0"
> > >> > >>> );
> > >> > >>> config.setUsername( “myUsername" );
> > >> > >>> config.setPassword( “myPassword" );
> > >> > >>>
> > >> > >>> HikariDataSource dataSource = new HikariDataSource( config
);
> > >> > >>> serverRuntimeBuilder = serverRuntimeBuilder.dataSource(
> dataSource
> > >> );
> > >> > >>>
> > >> > >>> Thanks,
> > >> > >>> - hugi
> > >> > >>>
> > >> > >>>
> > >> > >>>> On 7. mar. 2016, at 20:51, Andrus Adamchik <
> > andrus@objectstyle.org
> > >> >
> > >> > >>> wrote:
> > >> > >>>>
> > >> > >>>> Yep. Cayenne built-in pool is intentionally basic
with a
> minimal
> > >> > number
> > >> > >>> of features (Here we may be dealing with a bug though,
and I'd
> > like
> > >> to
> > >> > fix
> > >> > >>> it, but that's a separate issue). So yeah, using a third
party
> DS
> > >> may
> > >> > be a
> > >> > >>> good idea. Here is an example how you can set it up:
> > >> > >>>>
> > >> > >>>> DataSource ds = // instantiate it via API specific
to you DS
> > >> provider
> > >> > >>>>
> > >> > >>>> ServerRuntime runtime =
> > >> > >>> ServerRuntimeBuilder.builder().dataSource(ds).build();
> > >> > >>>> // of course add any other things you need to add
to the
> builder
> > to
> > >> > get
> > >> > >>> a working Cayenne stack.
> > >> > >>>>
> > >> > >>>> Andrus
> > >> > >>>>
> > >> > >>>>
> > >> > >>>>> On Mar 7, 2016, at 12:45 PM, Hugi Thordarson
<
> hugi@karlmenn.is>
> > >> > wrote:
> > >> > >>>>>
> > >> > >>>>> Thanks John! I’m going to try my hand at HikariCP.
> > >> > >>>>>
> > >> > >>>>> Are there any examples anywhere on how to configure
Cayenne to
> > >> use a
> > >> > >>> third party connection pool?
> > >> > >>>>>
> > >> > >>>>> Cheers,
> > >> > >>>>> - hugi
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>
> > >> > >>>>>> On 7. mar. 2016, at 20:39, John Huss <johnthuss@gmail.com>
> > >> wrote:
> > >> > >>>>>>
> > >> > >>>>>> EOF can do JNDI, but that's not going to
do anything to fix
> > your
> > >> > >>> problem.
> > >> > >>>>>>
> > >> > >>>>>> The connection pool in cayenne had some changes
somewhat
> > >> recently so
> > >> > >>> it's
> > >> > >>>>>> entirely possible there are bugs.
> > >> > >>>>>>
> > >> > >>>>>> In practice it turns out many people don't
use the connection
> > >> pool
> > >> > >>> built-in
> > >> > >>>>>> to Cayenne at all, and rather use a third-party
connection
> > pool,
> > >> of
> > >> > >>> which
> > >> > >>>>>> there are several.  The cayenne one is decent,
but it is very
> > >> > limited
> > >> > >>> in
> > >> > >>>>>> functionality and less robust due to having
a smaller user
> base
> > >> and
> > >> > >>> being a
> > >> > >>>>>> non-core feature.
> > >> > >>>>>>
> > >> > >>>>>> You can use another pool like:
> > >> > >>>>>> hikari <https://github.com/brettwooldridge/HikariCP>
- If I
> > was
> > >> > >>> starting a
> > >> > >>>>>> new project I'd use this
> > >> > >>>>>> tomcat-jdbc <
> > >> > https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html>
> > >> > >>> -
> > >> > >>>>>> This is what I currently use
> > >> > >>>>>> commonds-dbcp <
> https://commons.apache.org/proper/commons-dbcp/
> > >
> > >> > >>>>>> c3po <http://www.mchange.com/projects/c3p0/>
> > >> > >>>>>>
> > >> > >>>>>> The main reason I turned to a third-party
connection pool was
> > to
> > >> get
> > >> > >>>>>> fair-scheduling which will provide connections
to whoever has
> > >> been
> > >> > >>> waiting
> > >> > >>>>>> the longest, which helps avoid unnecessary
errors caused by
> > >> serving
> > >> > >>>>>> requests out of order.
> > >> > >>>>>>
> > >> > >>>>>> John
> > >> > >>>>>>
> > >> > >>>>>> On Mon, Mar 7, 2016 at 2:31 PM Michael Gentry
<
> > >> > mgentry@masslight.net>
> > >> > >>> wrote:
> > >> > >>>>>>
> > >> > >>>>>>> Well, I'm not sure what you are using
to run your web
> > >> application,
> > >> > but
> > >> > >>>>>>> Tomcat, Jetty, JBoss, etc all have mechanisms
to provide
> JNDI
> > >> > lookups
> > >> > >>> of DB
> > >> > >>>>>>> connection pools.  You just tell Cayenne
Modeler to use JNDI
> > >> lookup
> > >> > >>> and
> > >> > >>>>>>> give it the JNDI name, then configure
the container to
> provide
> > >> the
> > >> > DB
> > >> > >>>>>>> connection.
> > >> > >>>>>>>
> > >> > >>>>>>> Is your WO application using EOF or Cayenne?
 Been a while
> > >> since I
> > >> > >>> used WO,
> > >> > >>>>>>> but I'd be stunned if EOF cannot use
a JNDI lookup as well.
> > >> > >>>>>>>
> > >> > >>>>>>> mrg
> > >> > >>>>>>>
> > >> > >>>>>>>
> > >> > >>>>>>> On Mon, Mar 7, 2016 at 3:07 PM, Hugi
Thordarson <
> > >> hugi@karlmenn.is>
> > >> > >>> wrote:
> > >> > >>>>>>>
> > >> > >>>>>>>> Hi Michael,
> > >> > >>>>>>>> does using JNDI change anything about
the connection
> itself,
> > >> > isn’t it
> > >> > >>>>>>> just
> > >> > >>>>>>>> a different method of looking up
connection information?
> > >> > >>>>>>>>
> > >> > >>>>>>>> But I probably can’t use it anyway
since one of the apps
> is a
> > >> > >>> WebObjects
> > >> > >>>>>>>> app and doesn’t provide a JNDI
service (at least I’ve never
> > >> used
> > >> > it).
> > >> > >>>>>>>>
> > >> > >>>>>>>> Thanks,
> > >> > >>>>>>>> - hugi
> > >> > >>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>>> On 7. mar. 2016, at 19:13, Michael
Gentry <
> > >> mgentry@masslight.net
> > >> > >
> > >> > >>>>>>> wrote:
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> Hi Hugi,
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> Since this appears to be a web-based
application, can you
> > >> switch
> > >> > to
> > >> > >>>>>>> using
> > >> > >>>>>>>>> JNDI?
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> mrg
> > >> > >>>>>>>>>
> > >> > >>>>>>>>>
> > >> > >>>>>>>>> On Mon, Mar 7, 2016 at 5:46 AM,
Hugi Thordarson <
> > >> > hugi@karlmenn.is>
> > >> > >>>>>>>> wrote:
> > >> > >>>>>>>>>
> > >> > >>>>>>>>>> Hi all,
> > >> > >>>>>>>>>> This is still happening,
even after I added a
> > >> validationQuery,
> > >> > our
> > >> > >>> app
> > >> > >>>>>>>> is
> > >> > >>>>>>>>>> dying quite frequently :(.
 I’m not quite sure how to
> debug
> > >> > this,
> > >> > >>> is
> > >> > >>>>>>>> there
> > >> > >>>>>>>>>> any way for me to catch where
connections are being
> opened
> > in
> > >> > the
> > >> > >>> code
> > >> > >>>>>>>> and
> > >> > >>>>>>>>>> at what location they’re
hanging?
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>
> > >> > >>>
> > >> >
> > >>
> >
> https://www.dropbox.com/s/8jkmh6513s6wwkn/Screenshot%202016-03-07%2010.21.53.png?dl=0
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>> Cheer,
> > >> > >>>>>>>>>> - hugi
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>> // Hugi Thordarson
> > >> > >>>>>>>>>> // http://www.loftfar.is/
> > >> > >>>>>>>>>> // s. 895-6688
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>> On 29. feb. 2016, at
11:25, Andrus Adamchik <
> > >> > >>> andrus@objectstyle.org>
> > >> > >>>>>>>>>> wrote:
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>>> On Feb 29, 2016,
at 2:20 PM, Hugi Thordarson <
> > >> > hugi@karlmenn.is>
> > >> > >>>>>>>> wrote:
> > >> > >>>>>>>>>>>>
> > >> > >>>>>>>>>>>> What does validationQuery
do?
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>> Periodically executes
for each pooled connection, and
> > kills
> > >> > >>>>>>> connections
> > >> > >>>>>>>>>> that throw during validation.
So it ensures that all
> pooled
> > >> > >>>>>>> connections
> > >> > >>>>>>>> are
> > >> > >>>>>>>>>> in a good state.
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>> Andrus
> > >> > >>>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>>
> > >> > >>>>>>>
> > >> > >>>>>
> > >> > >>>>
> > >> > >>>
> > >> > >>>
> > >> > >
> > >> >
> > >> >
> > >>
> > >
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message