Hi,
Thanks for your question. What you are running into is actually not a Spring Integration issue per se, but your issue stems from Spring's Default Conversion Service, which gets initialized if not providing your own. The default conversion service actually tries to be as lenient as possible - Please see for details:
https://github.com/SpringSource/spri...onService.java
The problem specifically is the CollectionToObjectConverter (https://github.com/SpringSource/spri...Converter.java).
It uses the first item from the collection. There are a few solutions possible for your issue. In that regard, please also review the (short) chapter on 'Payload Type Conversion':
http://static.springsource.org/sprin...ype-conversion
In order to "fix" your issue, I see 3 options:
1) Setup your own Conversion Service (Use bean name: "integrationConversionService"). For example you may extend org.springframework.context.support.ConversionServ iceFactoryBean to achieve that and only add the converter that are relevant for your application.
If you are using Spring 3.0.x, please also see http://org.springframework.integrati...ServiceCreator as it contains a work-around for an issue.
2) You can provide your own converters, that are more restrictive e.g.:
Code:
<int:converter>
<bean class="org.springframework.integration.mycode.CollectionConverter"/>
</int:converter>
3) Or from a different angle, create a typed Channel e.g.:
Code:
<int:channel id="inputChannel" datatype="org.springframework.integration.mycode.User"/>
I hope this give you some options. Please let me know if you run into further issues or need more explanations.
Thanks!
Cheers,
Gunnar