Forest, I asked a very similar question last week that Mark Derricutt
helped me out with, so let me pay it forward by passing on the same
advice. Basically you want to setup two processors that will invoke your
Mailet. The first will be your "normal" processor and the second one
will be your "retry" processor. Then in your Mailet you will check your
remote system and if it is down then set the status on the mail object
to the name of your retry processor. In your Mailet, before your check
of the remote system, you will add a check of the mail object's status.
If it is "retry" then you will sleep for some amount of time before
checking the remote system again.

Here are some snippets from my config/Mailet to make this more concrete.
I should point out that I wound up adding an third, intermediate
processor because I couldn't get it working with just 2 processors for
some reason.

      <!-- primary queue -->
      <processor name="xt">
         <mailet match="All" class="XTMailet"/>
      </processor>
      
      <!-- retry queue -->
      <processor name="xt-retry">
         <mailet match="All" class="XTMailet"/>
      </processor>

      <!-- intermediate/re-routing queue -->
      <processor name="marketer-down">
         <mailet match="All" class="ToProcessor">
            <processor>xt-retry</processor>
         </mailet>
      </processor>
  
And some Mailet code:

if ("xt-retry".equalsIgnoreCase(mail.getState())) {
    Thread.sleep(RETRY_SLEEP_SECONDS * 1000);
}

if (serverUtil.isMarketerUp()) {
    processor.send(mail.getMessage());
} else {
    // Marketer is down so tell James to route this to the retry
processor
    mail.setState("marketer-down");
}


-----Original Message-----
From: Forest Zhu [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 21, 2007 4:54 AM
To: [email protected]
Subject: How to pause the process of mails in spool?

Hi,

I have written a mailet that invokes an outside rmi server to process
the
mail. Sometimes the rmi server is broken.

What I want is:
1. Check the rmi server status when a new mail arrives.
2. If the server is down, then put the mail in a "queue".
3. Every 5min check whether the server is up again. If the server is up
again, process the mail in the "queue".

Since I'm a newbie to james, I have no idea how to do this. Can anyone
give
me some hints?

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to