Configuring the AbstractMailReceiver's maxFetchSize property to match the poller's max-messages-per-poll value if available. Otherwise, setting to 1 to avoid lost mails (since pre-fetched mail messages would be added to the mailQueue and deleted from the server).
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.integration.mail.MailReceivingMessageSource;
|
||||
import org.springframework.integration.mail.Pop3MailReceiver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <inbound-channel-adapter> element of Spring
|
||||
@@ -59,6 +60,18 @@ public class MailInboundChannelAdapterParser extends AbstractPollingInboundChann
|
||||
if (StringUtils.hasText(propertiesRef)) {
|
||||
receiverBuilder.addPropertyReference("javaMailProperties", propertiesRef);
|
||||
}
|
||||
boolean configuredFetchSize = false;
|
||||
Element pollerElement = DomUtils.getChildElementByTagName(element, "poller");
|
||||
if (pollerElement != null) {
|
||||
String mmpp = pollerElement.getAttribute("max-messages-per-poll");
|
||||
if (StringUtils.hasText(mmpp)) {
|
||||
receiverBuilder.addPropertyValue("maxFetchSize", mmpp);
|
||||
configuredFetchSize = true;
|
||||
}
|
||||
}
|
||||
if (!configuredFetchSize) {
|
||||
receiverBuilder.addPropertyValue("maxFetchSize", 1);
|
||||
}
|
||||
return BeanDefinitionReaderUtils.registerWithGeneratedName(
|
||||
receiverBuilder.getBeanDefinition(), parserContext.getRegistry());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user