Re: How to do DB failover with WO
Re: How to do DB failover with WO
- Subject: Re: How to do DB failover with WO
- From: Mike Schrag <email@hidden>
- Date: Tue, 22 May 2007 11:29:27 -0400
For what it's worth, FrontBase supports clustering (and seamless
failover) out-of-the-box also. If you're looking for a cheap and
reliable way to get resiliency, FB's definitely worth a look.
ms
On May 22, 2007, at 11:20 AM, Tetsuya Takeo wrote:
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:
40mdimension.com
This email sent to 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