Our Integration services have a few setters and getters for various other services. I wish to use spel expressions to invoke only one (always one) of the actual method in any of the integration services.
The normal way of using service activators with the method attribute works fine. But i wish to return any type of Object from the integration service and using the spel expression in the next service activator to invoke the required method. But this leads to ambiguity.
exampleCaused by: java.lang.IllegalArgumentException: Found ambiguous parameter type
Code:public class AService { BService bService; CService cService; public CService getcService() { return cService; } public void setcService(CService cService) { this.cService = cService; } public BService getbService() { return bService; } public void setbService(BService bService) { this.bService = bService; } @Transactional() public void doBusiness1(String anything) { System.out.println("AServiceBusiness1"); } }Code:public class CService { } public class BService { } public class SomePayload { String anything; public String getAnything() { return anything; } public void setAnything(String anything) { this.anything = anything; } }Code:<int:channel id="input"/> <bean id="bService" class="a.b.c.BService"/> <bean id="cService" class="a.b.c.CService"/> <bean id="aService" class="a.b.c.AService"> <property name="bService" ref="bService"/> <property name="cService" ref="cService"/> </bean> <int:service-activator input-channel="input" ref="aService" expression="payload.anything" output-channel="logChannel"/>results inCode:MessageChannel inputChannel = appContext.getBean("input", MessageChannel.class); SomePayload somePayload = new SomePayload(); somePayload.setAnything("something"); Message msg = MessageBuilder.withPayload(somePayload).build(); inputChannel.send(msg);
I had thought that based on the expression result the appropriate method would be invoked ?Caused by: java.lang.IllegalArgumentException: Found ambiguous parameter type [interface java.util.List] for method match: [public void a.b.c.AService.doBusiness1(java.lang.String), public void a.b.c.AService.setcService(a.b.c.CService), public void a.b.c.AService.setbService(a.b.c.BService), public a.b.c.BService a.b.c.AService.getbService()]
I did not want to use multiple transformers (with their own channels) as they will all essentially be extracting the required attribute from the payload to invoke the next service.
Thanks in advance


Reply With Quote
