Results 1 to 3 of 3

Thread: Using the payload-type-router

  1. #1
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    160

    Default Using the payload-type-router

    Hi,
    we are in the process of migrating to spring-integration 2. In that process we are trying to make things easier than they are at the moment. One of the possible candidates to improve in the routing part. At the moment we have code like this:

    Code:
        <si:router input-channel="docTypeChannel" ref="docTypeRouter" method="resolveObjectTypeChannel"/>
        <si:channel id="News"/>
        <si:channel id="PressRelease"/>
        <si:channel id="Faq"/>
        <si:channel id="Address"/>
        <si:channel id="PB51Publication"/>
        <si:channel id="LeadingPage"/>
        <si:channel id="Bill"/>
        <si:channel id="CountryInformation"/>
        <si:channel id="TravelAdvice"/>
        <si:channel id="Webpage"/>
        <si:channel id="Delete"/>
    The router is a very basic implementation:
    Code:
        public String resolveObjectTypeChannel(Message message) {
            return message.getPayload().getClass().getSimpleName();
        }
    Now I would like to replace this with the existing payload type message router. If I understand well, I do need to provide a mapping between type and channel myself, would be nice if there could be a default resolving strategy like:
    - fully qualified class name
    - simple class name
    - custom mappings

    Am I wrong and is this possible?

    thanks,
    Jettro
    Jettro Coenradie
    http://www.gridshore.nl

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    How about using Spring Expression Language (SpEL):
    Code:
    <router input-channel="..." output-channel="..." expression="payload.getClass().getSimpleName()"/>
    In the above, the result of the expression will be the simple name of the class which is also a channel name in your config.

    That is why we invested so much time in providing support for SpEL in Spring INtegration 2.0

  3. #3
    Join Date
    Aug 2004
    Location
    The Netherlands
    Posts
    160

    Default

    I am not that used to SPeL, but indeed it works and I like this solution as well.

    thanks,
    Jettro
    Jettro Coenradie
    http://www.gridshore.nl

Posting Permissions

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