-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Handling sudden loss of DB connection in Windows Service
PostPosted: Wed Jun 27, 2007 11:06 pm 
Newbie

Joined: Tue Mar 13, 2007 9:00 pm
Posts: 5
Hi,

I've got a question on the best way to handle the DB going offline. I have a windows service, which has a number off threads actively interacting with the DB (SQL Server). I guess I'm thinking ahead of the actual problem - but what is the best way to deal with DB going offline in NHibernate? Are there any best practices or recommended approaches?

Using a try-catch approach inside of an infinite loop approach (it is highly unlikely the DB will be down for longer than 2-3 minuts) seems excessive (one way that i though of dealing with the issue)...

Any comments and recomendation will be much appreciated.

Thanks in advance,
Nick Goloborodko


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 4:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
As far as I am aware, the only recommendation NHibernate has regarding exception handling is described here:
http://www.hibernate.org/hib_docs/nhibe ... exceptions

The nature of most windows services is that they do the same thing over and over again. Therefore, running some form of an infinite loop is not unreasonable. Of course, you don't want to be hitting your database every millisecond. Depending on your need, I found that using a timer works for me. A few of my applications hit the database every few minutes to see if there is any work to do; if so, do it; if not, sleep and wait. If the database is not there... well, sleep and wait anyway.

Hope this helps.

_________________
Karl Chu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.