2012-12-19 27 views
2

我正在使用spring integration來檢索使用imap的電子郵件以下是我的配置:我正在使用spring - 集成版本1.0.4.RELEASE,我堅持這個版本,因爲我的春天版本是2.5,我不想改變(將花費很大的精力去做)。彈簧集成 - 屬性'should-delete-messages'不允許出現在元素'mail:inbound-channel-adapter'

問題 如果我在入站通道適配器中放入以下任何屬性,則會出現以下異常。 應該-刪除的消息= 「假」 應該標記的消息,如閱讀= 「真」

異常線程 「main」 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:在XML線路125來自類路徑資源[META-INF/spring/component.xml]的文檔無效;嵌套異常是org.xml.sax.SAXParseException:cvc-complex-type.3.2.2:屬性'should-delete-messages'不允許出現在元素'mail:inbound-channel-adapter'中。

此外,無論何時處理電子郵件,相應的電子郵件都將從Outlook郵箱中刪除。版本1.0.4中不支持該屬性?如果是,那麼如何實現類似的功能?

<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:[email protected]: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

通過使用IMAP的空閒信道適配器代替入站通道適配器的解決如下:

<mail:imap-idle-channel-adapter id="imapAdapter" 
            store-uri="imaps://username:[email protected]:993/inbox"          
            channel="recieveEmailChannel" 
            should-delete-messages="false" 
            auto-startup="true" 
            java-mail-properties="javaMailProperties" /> 
相關問題