Permalink
Browse files

BUGFIX. Save MimeMessage before QueueInfo, and set up MimeMessage not…

… found message before set FAILED state.
  • Loading branch information...
1 parent face018 commit f90fa144e90b06fae34b4fe287cf78dc2b4cfb71 @lsolova lsolova committed May 27, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/main/java/org/masukomi/aspirin/core/delivery/DeliveryManager.java
View
11 src/main/java/org/masukomi/aspirin/core/delivery/DeliveryManager.java
@@ -82,8 +82,8 @@ public String add(MimeMessage mimeMessage) throws MessagingException {
long expiry = AspirinInternal.getExpiry(mimeMessage);
Collection<InternetAddress> recipients = AspirinInternal.extractRecipients(mimeMessage);
synchronized (mailingLock) {
- queueStore.add(mailid, expiry, recipients);
mailStore.set(mailid, mimeMessage);
+ queueStore.add(mailid, expiry, recipients);
}
return mailid;
}
@@ -94,8 +94,8 @@ public MimeMessage get(QueueInfo qi) {
public void remove(String messageName) {
synchronized (mailingLock) {
- queueStore.remove(messageName);
mailStore.remove(messageName);
+ queueStore.remove(messageName);
}
}
@@ -113,8 +113,9 @@ public void run() {
MimeMessage message = get(qi);
if( message == null )
{
- qi.setState(DeliveryState.FAILED);
+ AspirinInternal.getLogger().warn("No MimeMessage found for qi={}",qi);
qi.setResultInfo("No MimeMessage found.");
+ qi.setState(DeliveryState.FAILED);
release(qi);
continue;
}
@@ -199,12 +200,12 @@ public void release(QueueInfo qi) {
if( qi.isInTimeBounds() )
{
qi.setState(DeliveryState.QUEUED);
- AspirinInternal.getLogger().trace("DeliveryManager.release(): Releasing: QUEUED.");
+ AspirinInternal.getLogger().trace("DeliveryManager.release(): Releasing: QUEUED. qi={}",qi);
}
else
{
qi.setState(DeliveryState.FAILED);
- AspirinInternal.getLogger().trace("DeliveryManager.release(): Releasing: FAILED.");
+ AspirinInternal.getLogger().trace("DeliveryManager.release(): Releasing: FAILED. qi={}",qi);
}
}
queueStore.setSendingResult(qi);

0 comments on commit f90fa14

Please sign in to comment.