Results 1 to 3 of 3

Thread: EAI: Content Based Filter with Spring Integration

Threaded View

  1. #1
    Join Date
    Nov 2012
    Posts
    2

    Default EAI: Content Based Filter with Spring Integration

    Hi there,

    I am trying to implement simple content based router using Spring integration and cannot figure out what should be the right way.

    Case
    On input channel I receive a simple XML message
    HTML Code:
    <passenger>
        <name>John</name>
        <age>28</age>
    </passenger>
    Based on the age value i want to determine whether a passenger is infant, child or adult, and direct message to a corresponding channel, i.e. infantChannel, childChannel or adultChannel. I want to use XPath to define conditions of the content based filter, since it is XML message.

    Apache Camel Solution
    With Apache Camel it is rather straight forward

    HTML Code:
    <route>
        <from uri="file:src/test/resources/message?noop=true"/>
        <choice>
            <when>
                <xpath>/passenger/age &lt;= '1'</xpath>
                <log message="INFANT"/>
            </when>
            <when>
                <xpath>/passenger/age &gt; '1' and /passenger/age &lt;= '12'</xpath>
                <log message="CHILD"/>
            </when>
            <when>
                <xpath>/passenger/age &gt; '12'</xpath>
                <log message="ADULT"/>
            </when>
            <otherwise>
                <log message="ERROR"/>
            </otherwise>
        </choice>
    </route>
    Spring Integration Solution
    Well... I wasn't able to figure out and run out of patience. That is why I am writing to this forum.

    It was logical to use <xpath-router>, but based on the documentation the output channels are determined dynamically based on the result of the XPath expression.

    What I am trying to do is the following
    HTML Code:
    <si-xml:xpath-router id="passengerRouter" input-channel="passengerChannel" resolution-required="true" >
        <si-xml:xpath-expression expression="/passenger/age"/>
    </si-xml:xpath-router>
    Based on the doc, the XPath expressions are evaluated as NODESET and converter to list of strings, where every value of this list represents a channel name to which this message will be sent. In my case this will be just a list of integers from <age> message element and this this is not what I want. I just have four channels I want the message to be sent to.

    So, my question is how to configure <xpath-router> to implement my case?

    Thanks in advance.
    Last edited by opatopa; Nov 4th, 2012 at 06:07 AM.

Posting Permissions

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