Announcement Announcement Module
No announcement yet.
Accepting only messages with payload of a certain type, rejecting Collection of type Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accepting only messages with payload of a certain type, rejecting Collection of type

    I'm using <service-activator> with a method that uses a domain object.
    I've noticed that when a message with a collection of that object is received the method is invoked with one element and the rest are discarded.

    Is this intentional? Is there a way to avoid this behavior without doing the checks in the code or using a splitter/filter?

  • #2

    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:

    The problem specifically is the CollectionToObjectConverter (

    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':

    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 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.:

        <bean class="org.springframework.integration.mycode.CollectionConverter"/>
    3) Or from a different angle, create a typed Channel e.g.:

    <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.





    • #3
      Just for reference, I added a documentation Jira in order to clarify and improve the documentation for Spring Integration 3.0:


      • #4
        Thank you for the quick answer.