advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Download the code for this article
Under which app-testing circumstances do notifications stop being a helpful service and start becoming a nuisance?
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
Average Rating: 4.5/5 | Rate this item | 2 users have rated this item.
 

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.

  Next Page: How the Servlet Determines Its Recipients


Page 1: IntroductionPage 3: Notification Overkill
Page 2: How the Servlet Determines Its RecipientsPage 4: A Notification Servlet Has Many Uses
Please rate this item (5=best)
 1  2  3  4  5
advertisement