user4176866
user4176866

Reputation:

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

Upvotes: 4

Views: 759

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

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.

Upvotes: 2

Related Questions