简体   繁体   中英

how to configure dynamic inbound for Spring integration mail?

I am new in spring mail integration, and bellow i put my configuration for mail:inbound-channel-adapter . But i want that the attribute store-uri to be dynamique, and i can update it from my Java controller. Because this attribute is not constante in my context of application.

<int-mail:inbound-channel-adapter id="pop3ShouldDeleteTrue"
                    store-uri="imaps://tata:tata@imap.gmail.com:993/inbox"
                    channel="receiveChannel"
                    should-delete-messages="true"
                    auto-startup="false"
                    java-mail-properties="javaMailProperties">
        <!-- Will poll every 20 seconds -->
        <int:poller fixed-rate="20000"/>
</int-mail:inbound-channel-adapter> 

The URL is a final field in the inbound adapter (actually an ImapMailReceiver component passed into a MailReceivingMessageSource ) so it can't be updated.

The only way to change the URL would be to rebuild both classes and inject them into the SourcePollingChannelAdapter that represents the inbound adapter.

However, that won't be thread-safe so I don't think it's safe to do that in a web container.

It's probably easier to simply construct an ImapMailReceiver on-demand and call the receive() method, then use a MessagingTemplate to send the message to a channel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM