Hello Guys
I have the follow
where the Java code isCode:<int:router id="router" input-channel="inicio" apply-sequence="true" resolution-required="true" default-output-channel="noTypeMatchChannel" method="metodoRouter01" ref="myRouterSinAnnotationUno" />
I am checking each payload type to return the name of the channel. Since I use a String return type for the method used by the Router.Code:public String metodoRouter01(Message<?> message){ logger.info(".... message: {}", message); if(message.getPayload() instanceof String) return "stringChannel"; else if(message.getPayload() instanceof Integer) return "integerChannel"; else if(message.getPayload() instanceof ItemArticulo) return "instrumentoMusicalChannel"; else return null; }
I could declared a static String[] type instead to get later a desired item through an index for each if/elseif scope to do the same approach
My problem is when I try to do the same with MessageChannel I mean, I must have the follow (code located in other class)
The code work fine, but I must declare each channel like a variable, it could be painful if my flow integration has 10 - 15 channels, exists a way to only declare for example just oneCode:private DirectChannel stringChannel; private DirectChannel integerChannel; private DirectChannel instrumentoMusicalChannel; @Value("#{stringChannel}") public void setStringChannel(DirectChannel stringChannel) { this.stringChannel = stringChannel; } @Value("#{integerChannel}") public void setIntegerChannel(DirectChannel integerChannel) { this.integerChannel = integerChannel; } @Value("#{instrumentoMusicalChannel}") public void setInstrumentoMusicalChannel(DirectChannel instrumentoMusicalChannel) { this.instrumentoMusicalChannel = instrumentoMusicalChannel; } public MessageChannel metodoRouter01(Message<?> message){ logger.info("... message: {}", message); if(message.getPayload() instanceof String){ return stringChannel; } else if(message.getPayload() instanceof Integer){ return integerChannel; } else if(message.getPayload() instanceof ItemArticulo){ return instrumentoMusicalChannel; } else return null; }
and in the if scope in someway just then indicate explicitly which Channel must be returned?Code:private DirectChannel directChannel; public void setDirectChannel(DirectChannel directChannel) { this.directChannel = directChannel; }
Thanks in advancedCode:if(message.getPayload() instanceof String){ //something to do get from my flow integration the stringChannel element return directChannel; }


Reply With Quote
ayload-type-router> with <mapping>?
