diff --git a/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/config/MailInboundChannelAdapterParser.java b/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/config/MailInboundChannelAdapterParser.java index 2d7ebe7446..3cbd040b4d 100644 --- a/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/config/MailInboundChannelAdapterParser.java +++ b/org.springframework.integration.mail/src/main/java/org/springframework/integration/mail/config/MailInboundChannelAdapterParser.java @@ -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()); }