You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Forest Zhu <fo...@gmail.com> on 2007/03/21 09:53:34 UTC

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.

RE: How to pause the process of mails in spool?

Posted by Scott Mitchell <sm...@silverpop.com>.
I see your point. In our situation we are only using James to provide an
SMTP front end to one of our systems so all inbound emails are being
sent though this Mailet so I think we should be OK. I will take a look
at the RemoteDelivery implementation to educate myself though.

Scott

-----Original Message-----
From: Stefano Bagnara [mailto:apache@bago.org] 
Sent: Thursday, March 22, 2007 8:59 AM
To: James Users List
Subject: Re: How to pause the process of mails in spool?

Scott Mitchell ha scritto:
> And some Mailet code:
> 
> if ("xt-retry".equalsIgnoreCase(mail.getState())) {
>     Thread.sleep(RETRY_SLEEP_SECONDS * 1000);
> }

Please note that implementing this logic inside a Mailet will "abuse" 
your spoolthread time

What I mean is that if you configured 10 spoolthreads and you have let's

say 100 messages to be retried you will end up delaying every incoming 
message by 10*RETRY_SLEEP_SECONDS seconds, even that mails that do not 
belongs to this processors.

A better way to implement retry logic would be to do something like the 
RemoteDelivery: the threads and the spool created by the RemoteDelivery 
already contains this logic, I suggest to look at that sources and try 
to reuse it.

We often discussed about extracting this logic from the RemoteDelivery 
so to provide the retry/delay features also in other spools, but we 
didn't implement it yet.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: How to pause the process of mails in spool?

Posted by Stefano Bagnara <ap...@bago.org>.
Scott Mitchell ha scritto:
> And some Mailet code:
> 
> if ("xt-retry".equalsIgnoreCase(mail.getState())) {
>     Thread.sleep(RETRY_SLEEP_SECONDS * 1000);
> }

Please note that implementing this logic inside a Mailet will "abuse" 
your spoolthread time

What I mean is that if you configured 10 spoolthreads and you have let's 
say 100 messages to be retried you will end up delaying every incoming 
message by 10*RETRY_SLEEP_SECONDS seconds, even that mails that do not 
belongs to this processors.

A better way to implement retry logic would be to do something like the 
RemoteDelivery: the threads and the spool created by the RemoteDelivery 
already contains this logic, I suggest to look at that sources and try 
to reuse it.

We often discussed about extracting this logic from the RemoteDelivery 
so to provide the retry/delay features also in other spools, but we 
didn't implement it yet.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: How to pause the process of mails in spool?

Posted by Scott Mitchell <sm...@silverpop.com>.
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:forzhu@gmail.com] 
Sent: Wednesday, March 21, 2007 4:54 AM
To: server-user@james.apache.org
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: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org