reniy
reniy

Reputation: 49

How to create beans from xml integration

I have code that should be rewritten to beans in java because I need to create multiple integration flows instead of one. For every customer.

I want to create JdbcPollingChannelAdapter bean for every customer using postProcessBeanFactory but I have no idea how to add channel for it.

<beans profile="retryProcessing">
        <bean id="jdbc-poll-for-email" class="org.springframework.integration.jdbc.JdbcPollingChannelAdapter">
            <constructor-arg value="dataSource"/>
            <constructor-arg value="SELECT RowID..."/>
            <property name="updateSql" value="UPDATE ${customer.catalog}...."/>
        </bean>
    </beans>

<int-jdbc:inbound-channel-adapter
            query="SELECT RowID, DocumentID..."
            channel="email.Channel" data-source="dataSource"
            update="UPDATE ${customer.catalog} SET Status=....">
        <int:poller fixed-rate="${emailAdvice.retry.period:60}" time-unit="SECONDS"/>
    </int-jdbc:inbound-channel-adapter>
    <int:channel id="email.Channel"/>
    <int:chain input-channel="email.Channel" output-channel="email.headerEnricherChannel">
        <int:splitter id="splitter"/>
        <int:header-enricher>
            <int:header name="inboxType" expression="payload.get('InboxType')"/>
            <int:header name="rowId" expression="payload.get('RowID')"/>
        </int:header-enricher>
        <int:transformer>
            <bean class="RowTransformer">
                <constructor-arg ref="transformRow"/>
            </bean>
        </int:transformer>
    </int:chain>

Upvotes: 1

Views: 52

Answers (1)

Gary Russell
Gary Russell

Reputation: 174769

This section of the manual shows how to find the classes involved for the channel adapter.

Specifically, you need a SourcePollingChannelAdapter and a JdbcPollingChannelAdapter for each one.

Also see the java DSL and, specifically Dynamic and Runtime Integration flows for the preferred mechanism for assembling flows programmatically.

Upvotes: 1

Related Questions