• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to do DB failover with WO
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to do DB failover with WO


  • Subject: How to do DB failover with WO
  • From: Tetsuya Takeo <email@hidden>
  • Date: Wed, 23 May 2007 00:20:35 +0900

Hi list,

I could not find how to do DB failover with WO, and managed to find a solution by myself. Not to repeat such effort, I'd like to make brief comment on this.

I have a system has two databases with replication. Everytime they copy changes each other, if one of the databases goes wrong, the other database runs continuously with same data sets. What I want to do is that, when an accident occurs on a db, then applications switches db, run as if nothing have happend.

My solution is, override WOApplication#handleException method to handle exception typical with DB connection trouble.

Code follows;
---
public WOResponse handleException(Exception ex, WOContext aContext) {
// Sometimes, it receives exception nested with NSForwardException, remove them.
while ( ex instanceof NSForwardException ) {
ex = (Exception)((NSForwardException) ex).originalException();
}
// TODO: It may not be good method to tell whether trouble is about DB connection.
if ( ex.toString().contains("_obtainOpenChannel") ) {
EOModel model = EOModelGroup.defaultGroup().modelNamed ("MyModel");
if ( model != null ) {
NSMutableDictionary newDict = new NSMutableDictionary ();
newDict.addEntriesFromDictionary (model.connectionDictionary());
newDict.setObjectForKey("<OTHER DB URL>", "URL");
// Very important spell
EODatabaseContext.forceConnectionWithModel(model, newDict, new EOEditingContext());
return aContext.page().generateResponse();
}
}
WOComponent nextPage = pageWithName( "ErrorPage", aContext );
nextPage.takeValueForKey( ex.toString(), "message" );
return nextPage.generateResponse();
}
---


This code returns the page which met the trouble. To consider improvements, show some message notifying users the DB trouble, switch db urls alternately, etc.

BTW, I cannot attend WWDC this year, have happy WWDC days to attender!
---
竹尾 哲也
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How to do DB failover with WO
      • From: Mike Schrag <email@hidden>
  • Prev by Date: Re: Popping-up a window and updating original page: how?
  • Next by Date: Re: How to do DB failover with WO
  • Previous by thread: Re: Popping-up a window and updating original page: how?
  • Next by thread: Re: How to do DB failover with WO
  • Index(es):
    • Date
    • Thread