Results 1 to 4 of 4

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

  1. #1

    Default 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. #2
    Join Date
    Aug 2005
    Location
    Atlanta
    Posts
    124

    Default

    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
    Gunnar Hillert
    SpringSource/VMWare, Spring Integration team
    SpringSource Team - Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/ghillert
    http://blog.hillert.com/
    http://blog.springsource.com/author/ghillert/

  3. #3
    Join Date
    Aug 2005
    Location
    Atlanta
    Posts
    124

    Default

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

    https://jira.springsource.org/browse/INT-2819
    Gunnar Hillert
    SpringSource/VMWare, Spring Integration team
    SpringSource Team - Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/ghillert
    http://blog.hillert.com/
    http://blog.springsource.com/author/ghillert/

  4. #4

    Default

    Thank you for the quick answer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •