I am using Spring Integration DSL configs. Is it possible to add a method reference handler such that the handler is invoked only when the message payload matches the handler argument type?
For example: in the following code, if the payload is MyObject2
, Spring will throw ClassCastException at handleMessage
. Instead, what I want to do is to bypass handleMessage
and get picked up by handleMessage2
.
@Bean
public IntegrationFlow myFlow() {
return IntegrationFlows
.from("myChannel")
.handle(this::handleMessage)
.handle(this::handleMessage2)
...
}
public MyObject2 handleMessage(MyObject o, Map headers){
...
}
public MyObject2 handleMessage(MyObject2 o, Map headers){
...
}