diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java index df363c0601..1714d88e4c 100755 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/AbstractMailReceiver.java @@ -60,7 +60,7 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl private volatile Folder folder; - private volatile boolean shouldDeleteMessages = false; + private volatile boolean shouldDeleteMessages; protected volatile int folderOpenMode = Folder.READ_ONLY; @@ -80,13 +80,13 @@ public abstract class AbstractMailReceiver extends IntegrationObjectSupport impl public AbstractMailReceiver(URLName urlName) { Assert.notNull(urlName, "urlName must not be null"); this.url = urlName; - this.shouldDeleteMessages = urlName.getProtocol().startsWith("pop3"); + //this.shouldDeleteMessages = urlName.getProtocol().startsWith("pop3"); } public AbstractMailReceiver(String url) { if (url != null) { this.url = new URLName(url); - this.shouldDeleteMessages = this.url.getProtocol().startsWith("pop3"); + //this.shouldDeleteMessages = this.url.getProtocol().startsWith("pop3"); } else { this.url = null; diff --git a/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd b/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd index 54277c890b..6d35bc7d6a 100644 --- a/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd +++ b/spring-integration-mail/src/main/resources/org/springframework/integration/mail/config/spring-integration-mail-2.0.xsd @@ -188,7 +188,7 @@ ]]> - + + + + + + + + + + + + diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/failed-imap-config.xml b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/failed-imap-config.xml new file mode 100644 index 0000000000..a47cddc3e1 --- /dev/null +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/failed-imap-config.xml @@ -0,0 +1,15 @@ + + + + + + + + diff --git a/src/docbkx/mail.xml b/src/docbkx/mail.xml index 1701c8754b..070efcf4e8 100644 --- a/src/docbkx/mail.xml +++ b/src/docbkx/mail.xml @@ -72,9 +72,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mail="http://www.springframework.org/schema/integration/mail" xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/integration/mail - http://www.springframework.org/schema/integration/mail/spring-integration-mail-1.0.xsd">]]> + http://www.springframework.org/schema/integration/mail/spring-integration-mail-2.0.xsd">]]> To configure an outbound Channel Adapter, provide the channel to receive from, and the MailSender: @@ -122,8 +122,28 @@ ]]> - When using should-mark-messages-as-read be aware of the protocol you are using ti retrieve messages. For example POP3 does not support this flag - which means setting it to 'true' will have no effect. + + In both configurations channel and should-delete-messages are the REQUIRED +    attributes. The important thing to understand is why should-delete-messages is required? +    The issue is with POP3 protocol, which does NOT have any knowlege of messages that were READ. It can only know what's been read  +    within a single session. This means that when your POP3 mail adapter is running emails are successfully consumed as as they become available during each poll +    and no single email message will be delivered more then once. However, as soon as you restart your adapter and begin a new session +    all the email messages that might have been retreeved in the previous session will be retrieved again. That is the nature of POP3. Some might argue +    that why not set should-delete-messages to TRUE by default? Becouse there are two valid amd mutually exclusive use cases  +    which makes it very hard pick the right default. You may want to configure your adapter as the only email receiever in which +    case you want to be able to restart such adapter without fear that messages that were delivered before will not be redelivered again.  +    In this case setting should-delete-messages to TRUE would make most sence. However, you may have anoher use case where  +    you may want to have multiple adapters that simply monitor email servers and their content. In other words you just want to 'peek but not touch'.  +    Then setting should-delete-messages to FALSE would be much more appropriate. So since it is hard to choose what should be +    the right default value for should-delete-messages attribute we simply made it required to be set - leaving it up to you +    while also not letting you to forget that you must set it. + + + When configuring a polling adapter (e.g., inbound-channel-adapter) should-mark-messages-as-read + be aware of the protocol you are configuring to retrieve messages. For example POP3 does not support this flag + which means setting it to either value will have no effect as messages will NOT be marked as read + + When using the namespace support, a header-enricher Message Transformer is also available. This simplifies the application of the headers mentioned above to any Message prior to sending to the