I have the following configuration, and I used the following style used in Spring integration Java DSL service actuator (.handle) should use bean
@Bean
public IntegrationFlow flow(PollerMetada poller, FileReadingMessageSource source){
return IntegrationFlows.from(source, e->e.poller(poller)
.handle(this::mainHandle)
.channel("somechannel")
.get();
}
public FileRequest mainHandle(Message<?> message){
...
return request;
}
But I got error my handler is a one-way MessageHandler, how to make it not a one way so I can configure the output channel? Thank you
You use
.handle(this::mainHandle)API. This one fully fits into aMessageHandlercontract:void handleMessage(Message<?> message). Where your method is like thismainHandle(Message<?> message). So, the return type of your method is ignored because that method reference mapped to theMessageHandlerknows nothing about return type - justvoid.To make it working with the return type you need to use different API:
where contract is this:
To match it into your
mainHandle()contract it has to be used like this:Or you can use method name-based API: