Jackie Dong
Jackie Dong

Reputation: 813

One email inbound adapter for multiple email address

We have more than 200 email addresses which are used to do integration with our customers, and most of the email process logic are same, we want to migrate those emails to Spring integration inbound email adapter, however we don't want to repeat copy and paste following code snippet

 <int-mail:imap-idle-channel-adapter id="mailAdapter"
                                        store-uri="${uri}"
                                        channel="emailInboundChannel"
                                        auto-startup="true"
                                        should-delete-messages="false"
                                        search-term-strategy="unseenSearchTermStrategy"
                                        java-mail-properties="javaMailProperties">
        <int-mail:transactional synchronization-factory="syncFactory" transaction-manager="transactionManager"/>
    </int-mail:imap-idle-channel-adapter>

Is there any way that we can just use one email adapter with fixed rate poller to connect to as many email address as we can , then send the email message to same inbound channel?

Upvotes: 2

Views: 276

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121177

If you can move to Java & Annotations configuration, especially Java DSL, then you can get a gain of dynamic flows: https://docs.spring.io/spring-integration/docs/5.3.1.RELEASE/reference/html/dsl.html#java-dsl-runtime-flows. So, you could iterate over your emails and register IMAP channel adapters for them.

This is really hard to do with an XML configuration...

You can consider to use a spring-integration-flow extension though: https://github.com/spring-projects/spring-integration-flow, but it’s really recommended to move to Java configuration these days.

Upvotes: 3

Related Questions