james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oki DZ <ok...@pindad.com>
Subject RemoteDelivery
Date Tue, 07 Aug 2001 07:39:38 GMT

Would there be any problem if the retried message just be pushed back into
the outgoing spool without renewing the message name? 

RemoteDelivery.java, starting line #246:
if (!mail.getState().equals(Mail.ERROR)) {
			int retries =
			if (retries < maxRetries) {
				//Change the name (unique identifier) of
this message... we want to save a new copy
				// of it, so change the unique idea for
				mail.setName(mail.getName() + retries);
				log("Storing message " + mail.getName() +
" into outgoing after " + retries + " retries");
				mail.setErrorMessage(retries + "");

I believe that the main reason of the message name renaming is to have a
copy of the processed message so that when it is deleted (in
RemoteDelivery.run()), the copy can be resent in the next run. This would
slow down JDBCSpoolRepository, I think. Because when you store() a
message, the method will see wether the message body was updated, but only
the body of the message which has the same message name as what it had

When you store() a new message, then you will retrieve the message from
the database server, put each 1024K chunk of the message in memory, and
then send each chunk back to the server.  This could make James go into a
crawl if you have many messages with large attachments that are retried to
be sent. (Besides, I'm having problem with my spool repository
implementation, due to the "always changing" message names. ;-)

I think to overcome the problem, the following snippet can be used. All
you need to do is to add "sent" state in the Mail interface. (Yes, it's an
additional "if"; but, you already an if in JDBCMailRepository for checking
an updated message body. This one is just the pair of it.)

In the run() method:
while (!Thread.currentThread().interrupted()) 
     try {
        String key = outgoing.accept(delayTime);
        log(Thread.currentThread().getName() + " will process mail" + key);
        MailImpl mail = outgoing.retrieve(key);
        if (mail.getState(Mail.SENT)) // sure, in deliver() the 
           outgoing.remove(key);      // message should be set to SENT
        else                          // on a successful delivery
           deliver(mail, session);       
        mail = null;
     } catch (Exception e) {
        log("Exception caught in RemoteDelivery.run(): " + e);

I don't know whether this one will work; I didn't test it. But I think it
would. There would be no problem with the other kinds of repositories,
wouldn't it?

BTW, I'd like to have more detailed error messages; something like
"address not found", "server time out", etc. Just having a Mail.ERROR
state is not sufficient. On a bounced message, I think the user would like
to know what has happened to his/her message.

Just some ideas,

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

View raw message