Search code examples
spring-integrationspring-integration-dsl

How to parameterize an object in integration flow?


I has integration flow for polling data from database. I set up message source which return list of object, this list I want to pass to method handle in subFlow.

It's code for this goals, but I get a compilation error: incompatible types Message to List.

@Bean
    public IntegrationFlow integrationFlow(
            DataSource dataSource,
            MessageHandler amqpHandler,
            PersonService personService,
            PersonChecker personChecker) {
        return IntegrationFlows
                .from(getMessageSource(personService::getPersons), e -> e.poller(getPollerSpec()))
                .wireTap(subFlow -> subFlow.handle(personChecker::checkPerson))
                .split()
                .publishSubscribeChannel(pubSub -> pubSub
                        .subscribe(flow -> flow.bridge()
                                .transform(Transformers.toJson())
                                .handle(amqpHandler))
                        .subscribe(flow -> flow.bridge()
                                .handle(personService::markAsSent)))
                .get();
    }

I know about solution to pass service and name of method handle(personChecker, checkPerson), but it's not suitable for me.

Is exists possibility to pass in wireTap subflow in method handle list with objects Person instead Message message?


Solution

  • .handle((p, h) -> personService.checkPerson(p))