Database fail over

Greetings,

I have been tasked with creating some code that will send out notification when we have a database error. I sent a request like like to the CF-Talk list asking if anyone had any suggestions.
We are using ColdBox for this task and the person spot seemed to be here: onApplicationStart

I also found some code that would do exactly what I wanted. See: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d48.html

I copied the source word for word and put it in my source. I wanted to make it break to test it.

//Load ColdBox application.cbBootstrap = CreateObject("component","coldbox.system.Coldbox").init(COLDBOX_CONFIG_FILE,COLDBOX_APP_ROOT_PATH,COLDBOX_APP_KEY,COLDBOX_APP_MAPPING); application.cbBootstrap.loadColdbox();

application.this_page = “/index.cfm”;
application.this_domain = “#cgi.server_name##Replace (cgi.path_info, ‘/#application.this_page#’, ‘’, ‘ALL’)#”;
application.dsn = “dsn”;
application.app_name = “appname”;
application.application_name = “appname”;
return true;

SELECT Emp_ID FROM employee This application encountered an error
Please contact support. Application.availableResources=0; Application.counter1=1;

I used a DB by the name of newDB155 as it doesn’t exist and it should make it fail. However, for some reason this works just fine.
Overall, the goal is to make sure we can get a message to the user that there is an issue and to send an email to the developers.
If anyone has any other suggestions, please let me now.

Thanks!

The problem is that on app start only fires 1, so this will only work 1 every 5 days or so or whatever your application is set to.

I would recommend creating a preProcess interceptor that checks and notifies for you, also maybe use cfthread so it does not take up resources on the incoming request.

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

This would not capture all DB errors, as it will only check if it is running. A DB can go down when the App is running, or throw any other type of error after this code has executed.

The best option is an interceptor for exception errors and then check to see if the type of it is a database, and then send an email out.

Thanks for the feedback! I’ll be re-engineering this.

Luis,

Have you all done a tutorial on writing an interceptor from scratch? If not, do you have an handy links on creating one. I think this is my best bet on getting this done.

Thanks,

Mallory

Here is our Vimeo channel for this: http://vimeo.com/channels/coldbox
Docs
http://wiki.coldbox.org/wiki/Interceptors.cfm

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Thanks for the links!