Ajay Chitre ha scritto:
Hello,

In our application, under certain error conditions, we would like to retry X
number of times after say every Y number of minutes and then if the error
still persists, ghost the message.  I searched the Mail archives, and
noticed that some people are writing special code to handle this, but most
of these messages are more than a year old.

Thought by now this functionality might be built into James.  I looked at
the docs, but couldn't find anything obvious.

Can someone please point me in the right direction?

No built in way, yet.

The easiest way is to start from RemoteDelivery code and write your own logic.

Half of RemoteDelivery code deal with placing the mail to be processed in another spool (named outgoing in this case) and then start a pool of threads dealing with delivery for this.

public void service(Mail mail) is the method where you take the mail from the main spool and put it in your "retrying" spool. RemoteDelivery also spit each Mail in multiple mails based on the recipients domains, but maybe you don't need this and just need to store the message to your retrying spool.

public void run() is the code executed by the worker threads. You can see that at some point (after delivery specific code) is starts a loop and inside the loop it calls the "deliver(mail, session)".

So, you can simply change it to "process(mail)" and then write your process code.

That code will retry the message as long as process(mail) will return false, and will delete the message from the spool when process(mail) returns true.

HTH,
Stefano

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

Reply via email to