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 PROTECTED]



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/mschrag% 40mdimension.com

This email sent to [EMAIL PROTECTED]


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to