0

Is there a way to ask NHibernate to automatically retry failed connections to a database? Specifically, if my network connection is too unreliable, sometimes NH will fail to connect to my remote SQL Server.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
David Pfeffer
  • 38,869
  • 30
  • 127
  • 202

1 Answers1

2

You might (just an idea) be able to get retries by overriding the connection driver's GenerateCommand() method. There you would return a wrapped IDbCommand that retries as necessary.

If you are working with "occasionally connected" requirements, see this question.

Community
  • 1
  • 1
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
  • We are working with what I'd like to call "usually connected" requirements -- a cellular connection on a bus that drives around and sometimes enters spotty cellular coverage. That question link is perfect though. – David Pfeffer Aug 13 '10 at 00:45
  • 1
    This is also a problem when working with SQL Server in a high availability environment. You need to be able to deal with the fact that the physical SQL server your connection is held too might go away in some sort of rollover scenario. – Nic Strong Sep 09 '10 at 05:05