Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Build a Notification Servlet That E-mails Exceptions to App Developers

Implement a mechanism that notifies the appropriate developer via e-mail whenever an exception occurs during application testing. With a little bit of effort, you can build a notification servlet that will enable such a mechanism.


advertisement
In a typical software development organization, the tasks of development and formal testing are performed by different groups of people. Testing groups commonly encounter application exceptions during their testing processes. All such exceptions typically are recorded as bugs in a bug-tracking system.

Eventually, the bugs make it to the developer whos actually in charge of the source code. Once the developer reads the verbose description of the bug—in the terminology of the tester—the developer sets out to simulate this bug in the development environment. If the developer can accurately reproduce the bug, he or she then obtains a stack trace of the exception and uses it to debug and finally fix the programming error.

This cycle typically spans over days. Wouldn't it cut down a lot of time and effort if whenever an exception occurred in the application, the appropriate developer for that application was notified with an e-mail and also received a stack trace related to the exception? With a little bit of effort, you can implement a mechanism that does just that.



Build a Notification Servlet
Every application infrastructure has its own exception-handling mechanism. For simplicity, lets consider a class UserDefinedException that extends java.lang.Exception. This class usually customizes exception handling for a particular application. Typically, the UserDefinedException class logs exceptions to a database and provides user-friendly messages, along with exception ids, that a developer can look up in the database to get the complete description of the exception (when it occurred, etc.). Such a UserDefinedException class should be enhanced so that it provides one more feature: sending a HTTP request to a notification servlet!

You might ask: Why a servlet? Why not send notifications from within the UserDefined class? The reason is a servlet would decouple the exception notification mechanism from the actual application, allowing the notification mechanism to be developed/maintained independently. It can be enhanced periodically without impacting regular application development in any way.

The notification servlet is responsible for:

  1. Analyzing the exception
  2. Deciding which course of action to take depending on the severity of the exception
  3. Creating a formatted message that contains the exception or its summary
  4. Deciding which output channel to use for sending out the notification, for example e-mail or wireless device
  5. Actually sending out the notification

Typically, if the exception's severity is non-critical, the servlet decides to ignore the exception and not send out any notifications. If the exception is moderately critical, the servlet might send out an e-mail notification, and in case of a severely critical exception, the servlet can send out a notification on a wireless phone.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date