This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello - We have a service that connects to 2 databases. One is a local SQL Server instance, the other is an Oracle database that may be located at the end of a long, slow pipe (VPN from the UK to Nebraska, USA). I would like to plan ahead for timeouts when querying the distant Oracle database. I don't anticipate timeouts when accessing the local SQL Server database... :) I use 2 different basic methods to query the Oracle database. The first is of the form:
The second form is like this:
So I have 2 questions that need answers: First, what exception should I be looking for in the case of a timeout, and are there other failure modes I should be looking for? Will I even get an exception or will I get some other failure on a timeout? Second, what is the best method for catching said errors/exceptions and retrying the query without borking Lightspeed's logic? I don't quite know how to simulate this situation. I suppose a test framework with a full-featured mocking setup would do the trick, but we have no such animal... Thanks for any tips, ideas, suggestions, caveats, etc. Dave |
|
|
LightSpeed doesn't specifically enforce a timeout but all of the underlying database providers will. So what you will see in a timeout situation is a provider specific exception being thrown e.g. SQL Server throws a SqlException. If you get such an exception you may need to reset the underlying database connection which generally would mean recycling the UnitOfWork, however that wont be so good if you actually want to retry logic within the active UnitOfWork such as persisting the changes so you will want to implement a custom connection strategy to handle this. Have a look at http://www.mindscapehq.com/documentation/lightspeed/Building-Applications-with-LightSpeed/Customising-How-LightSpeed-Connects-to-the-Database for details on how you go about this and let us know if you have any questions on this :)
|
|
|
Thanks, I'll have to figure out what the Oracle provider throws in that situation. I have my services split into read and update services (I forgot to include the update scenarios in my earlier post), so in the read service I can simply recycle the UnitOfWork. Things may get ugly before I'm through, but it can be done. :) In the update service I may be able to do the same thing, as we're only changing one or two field values - I can reapply the changes each time through. If that doesn't work, the customized connection strategy looks like it will do what I need it to do. I still need to mock this somehow -- maybe I can make a case with the boss to spend some money here. Any suggestions as to a good mocking platform? What do you guys use? Thanks again, Dave |
|
|
We have generally used Moq in recent times :) You can install this quickly via NuGet (Moq package).
|
|