2
votes

I am using spring integration to retrieve emails using imap the following is my configuration: I am using spring-integration version 1.0.4.RELEASE, I am sticking to this version because my spring version is 2.5 which I don't want to change (will take high effort to do).

Question If I put any of the following attributes in inbound-channel-adapter then I am getting the following exception. should-delete-messages="false" should-mark-messages-as-read="true"

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 125 in XML document from class path resource [META-INF/spring/component.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'should-delete-messages' is not allowed to appear in element 'mail:inbound-channel-adapter'.

Also whenever I process an email the corresponding email is getting deleted from outlook mailbox. Is this attribute not supported in Version 1.0.4? If yes then how to achieve the similar functionality?

<util:properties id="javaMailProperties">
    <prop key="mail.imap.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
    <prop key="mail.imap.socketFactory.fallback">false</prop>
    <prop key="mail.store.protocol">imaps</prop>
    <prop key="mail.debug">false</prop>
</util:properties>

<mail:inbound-channel-adapter id="imapAdapter"
                                  store-uri="imaps://username:password@mydomain:993/inbox"                                    
                                  channel="recieveEmailChannel"
                                  auto-startup="true"
                                  java-mail-properties="javaMailProperties">
    <int:poller> 
    <int:interval-trigger initial-delay="1000" interval="2000"
    fixed-rate="true"/>
    </int:poller>
</mail:inbound-channel-adapter>
<int:channel id="recieveEmailChannel" />        
<int:service-activator input-channel="recieveEmailChannel" ref="emailReceiverService" method="receive"/>
<bean id="emailReceiverService" class="com.mydomain.email.in.DefaultEmailReceiverUtilService">
</bean>
1

1 Answers

1
votes

Resolved by using imap-idle-channel-adapter instead of inbound-channel-adapter as follows:

<mail:imap-idle-channel-adapter id="imapAdapter"
                                  store-uri="imaps://username:password@mydomain:993/inbox"                                    
                                  channel="recieveEmailChannel"
                                  should-delete-messages="false"
                                  auto-startup="true"
                                  java-mail-properties="javaMailProperties" />