- Log.setThreadAnnotation("[outgoing smtp] ");
- int[] outgoing = store.list();
- Log.info("outgoing thread started; " + outgoing.length + " messages to send");
- for(int i=0; i<outgoing.length; i++) queue.append(store.get(outgoing[i]));
- while(true) {
- int num = queue.size();
- for(int i=0; i<num; i++) {
- Message next = queue.remove(true);
- if (!attempt(next)) queue.append(next);
- }
- synchronized(Outgoing.class) {
- Log.info("outgoing thread going to sleep");
- Outgoing.class.wait(10 * 60 * 1000);
- deadHosts.clear();
- Log.info("outgoing thread woke up; " + queue.size() + " messages in queue");
+ try {
+ Log.setThreadAnnotation("[outgoing smtp] ");
+ int[] outgoing = FileSystem.root.slash("outgoing").list();
+ Log.info(SMTP.Outgoing.class, "outgoing thread started; " + outgoing.length + " messages to send");
+ for(int i=0; i<outgoing.length; i++) queue.append(FileSystem.root.slash("outgoing").get(outgoing[i]));
+ while(true) {
+ int num = queue.size();
+ for(int i=0; i<num; i++) {
+ Message next = (Message)queue.remove(true);
+ boolean good = false;
+ try {
+ good = attempt(next);
+ } catch (IOException e) {
+ Log.error(SMTP.Outgoing.class, e);
+ } finally {
+ if (!good) queue.append(next);
+ }
+ }
+ synchronized(Outgoing.class) {
+ Log.info(SMTP.Outgoing.class, "outgoing thread going to sleep");
+ Outgoing.class.wait(10 * 60 * 1000);
+ deadHosts.clear();
+ Log.info(SMTP.Outgoing.class, "outgoing thread woke up; " + queue.size() + " messages in queue");
+ }