简体   繁体   中英

Converting Spring integration xml to Java DSL - Invoke method in Inbound Channel adapter

I have a xml as follows:

    <int:inbound-channel-adapter id="tasksForResendingToAggregatorPoller" ref="taskProcessor"
                                 method="getTaskIdForResendingToAggregator"
                                 channel="resultAggregationChannel" auto-startup="false">
        <int:poller max-messages-per-poll="-1" fixed-delay="#{1 * T(org.apache.commons.lang3.time.DateUtils).MILLIS_PER_HOUR}" receive-timeout="-1"/>
    </int:inbound-channel-adapter>

    <int:channel id="resultAggregationChannel" datatype="java.lang.Long">
        <int:queue capacity="${maxNumberOfMessagesInBuffers}"/>
    </int:channel>

How do I change this to Java DSL? I have tried below code but its incomplete. Im not sure how to add the 'ref' and 'method' attribute.

@Bean(name= PollerMetadata.DEFAULT_POLLER)
    public PollerMetadata defaultPoller() {
        return Pollers.fixedDelay(DateUtils.MILLIS_PER_HOUR).receiveTimeout(-1).get();
    }

    @Bean
    public MessageChannel resultAggregationChannel() {
        return MessageChannels.queue(bceMaxNumberOfMessagesInBuffers).get();
    }
    @Bean
public IntegrationFlow taskAgregator() {
        return IntegrationFlows.from("resultAggregationChannel")
                .handle(getEnrichmentTaskIdForResendingToAggregator)
                .get();

    };

IntegrationFlows.from(() -> bean.method(), e -> e.poller(...))
    .handle(...)
    ...

It doesn't make sense to use a queue channel there.

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