Inline response.
On 1 July 2013 12:44, Howard W. Smith, Jr. <[email protected]> wrote: > my response below... > > On Fri, Jun 28, 2013 at 11:45 AM, James Green <[email protected] > >wrote: > > > > > On boot our application attempts to read data through a JPA > EntityManager. > > If the database connection fails at this point the entire application is > > effectively dead. > > > > Is there an assumption or history that has informed you that database was > not available at boot/startup of the 'app'? > It happened. The database is on another machine. Both machines rebooted, TomEE started before the MySQL box did, simple. > > > > > > Is there a way to essentially ask the database layer to retry until the > > connection springs to life? > > > > I really don't see the need for this. I would assume that you can do all > you need to do with/in a CDI @ApplicationScoped @PostConstruct; this works > for me, in my app, but I don't have a need to keep trying to test my > database connection or retrieve data from my database connection on startup > (before any users begin connecting to the app). > > However, I do have the following @Schedule 'timer' implementation, which > checks an email acct every 2 minutes 'after' the app starts, and there is > code in there that will use JPA to perform SELECT and INSERT operations > against the database... and the assumption is that the database connection > is always valid...after a valid 'start' (which is usually, stop tomee, > deploy WAR, start tomee). When I have power outages, database always starts > successfully when tomee starts via Windows Service when server boots back > up. using apache derby instead of mysql. > That sounds like quite a narrow environment to test against. Perhaps you told Windows that TomEE depends on Derby thus creating a per-machine lock-step? > > /** > * > * @author Administrator > * > * http://tomee.apache.org/examples-trunk/access-timeout/README.html > * http://tomee.apache.org/examples-trunk/access-timeout-meta/ > * http://docs.oracle.com/cd/E19798-01/821-1841/gipsz/index.html > */ > @Singleton > @Lock(LockType.WRITE) > @AccessTimeout(value = 2, unit = TimeUnit.MINUTES) > public class EmailRequestBean { > > @Schedule(hour="*", minute="*/2", second="0", persistent=false) > public void downloadEmailRequests() { >
