[Opensource] Bug sending Job completion notices

Ken Chow kckc at shaw.ca
Fri Feb 28 01:01:12 PST 2003


When registering a user with email validation enabled for Expresso 5.0.3, I
noticed that a "System Error" email is always sent in addition to the "Job X
Completed" email. The contents of both emails are the same and state that
the "Registration Email Validation" job succeeded. I tracked down the source
of the "System Error" email to the finish(String msg, Exception ex) method
in com.jcorporate.expresso.core.job.Job.java and found that:

   new Event(dbName, "SYSERROR", mailmsg.toString(), success);

was being called irregardless of whether the job failed or completed
successfully. To correct the problem, I changed the code:

   if (ex != null) {
    log.error("Job " + jq.getField("JobNumber") +
      " failed in db '" + jq.getDBName() + "'", ex);
    mailmsg.append("Job '" + getClass().getName() + "' Failed. " +
      " Job Number :" + getJobNumber() +
      " from User '" + getUser() + "'");
   } else {
    log.debug("Notifying user " + u.getUid() +
      " that job completed successfully");
    mailmsg.append("Job " + jq.getField("JobNumber") +
      " Completed");
    u.notify("Job " + jq.getField("JobNumber") + " Completed",
      mailmsg.toString());
   }

   new Event(dbName, "SYSERROR", mailmsg.toString(), success);

to:

   if (ex != null) {
    log.error("Job " + jq.getField("JobNumber") +
      " failed in db '" + jq.getDBName() + "'", ex);
    mailmsg.append("Job '" + getClass().getName() + "' Failed. " +
      " Job Number :" + getJobNumber() +
      " from User '" + getUser() + "'");
    success = false;
   } else {
    log.debug("Notifying user " + u.getUid() +
      " that job completed successfully");
    mailmsg.append("Job " + jq.getField("JobNumber") +
      " Completed");
    u.notify("Job " + jq.getField("JobNumber") + " Completed",
      mailmsg.toString());
   }

   if (!success) {
      new Event(dbName, "SYSERROR", mailmsg.toString(), success);
   }


NOTE: For our application, we also disabled the code that sends the job
succeeded email, since we don't want to be SPAMMED with hundreds or possibly
thousands of emails from all the successful jobs. We only want to be
notified if there is a problem.

Ken Chow
kckc at shaw.ca






More information about the Opensource mailing list