Announcement Announcement Module
Collapse
No announcement yet.
simple workflow with SI? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • simple workflow with SI?

    i want to do a very simple workflow with Spring Integration. something like you have number of services and i want to introduce content-based routing between them

    so lets say a "gateway" receives a method invocation with an object as parameter. then first service in the chain gets a method invoked, then the next one in chain, then the one after that and so on, with possibilities to choose the route based on some properties of the object. after the last service has proceeded, it "returns" (as if the whole chain was a single method invocation, and is completely transparent to the initial caller). i used to do that sort of stuff with Camel, but now i'd like to use Spring Integration for various reasons.

    i tried to google, but all the tutorials i could find only cover jms, mail or file stuff and it's never mentioned that content-based routing between beans is possible. can someone please point me out a manual or a good example?

  • #2
    Spring Integration does support content-based routing in a number of ways. You should be able to get a general overview from the "Router" chapter of the reference manual: http://static.springsource.org/sprin...ce.html#router

    Also, you might want to look at the "oddeven" and "cafe" samples that are included with the distribution. Both show examples of content-based routing.

    Here's an example of a POJO router:
    Code:
    <router input-channel="in" ref="pojo" method="someMethodThatReturnsChannelOrChannelName"/>
    Here's an example of a SpEL router (in 2.0 milestones):
    Code:
    <router input-channel="in" expression="payload.balance gt 100000 ? 'high' : 'low'"/>
    There are also several simple configuration-driven routers available, such as "recipient-list-router", "payload-type-router", and "header-value-router".

    Hope that helps.
    -Mark

    Comment


    • #3
      yes, me stupid, i found that myself after i've posted, though true content-based routing it seems was only introduced in 2.0 (with expressions). i'd be looking forward to 2.0 release .

      one more thing, i tried to use the payload-type-router tag, but spring always throws me
      Code:
      cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'payload-type-router'
      while spring integration jar (-core one) is certainly on the classpath and the error never happens for any other tag like 'gateway', or 'router', or whatever else. what's wrong with this one? SI version i use is 1.0.2.SR1.

      Comment


      • #4
        The namespace support for "payload-type-router" was added in 1.0.3. You should upgrade if possible (it's the latest stable version currently).

        The link I sent above was for the 2.0 milestone reference.

        I'm not sure what you mean by "true content-based routing". Invoking a POJO that decides what channel to send to based on the Message payload content is of course also "content-based routing".

        Comment


        • #5
          I'm not sure what you mean by "true content-based routing". Invoking a POJO that decides what channel to send to based on the Message payload content is of course also "content-based routing".
          well, not if i have to write my own engine which will deduce the channel by a certain value of a specific property . availability of that kind of engine out-of-box (which will be the case in 2.0) is what i call true content-base routing.

          anyway thanks for the hint with the version, it turned out that our maven central mirror didn't have 1.0.3, that's why i saw 1.0.2.SR1 as the latest.

          Comment


          • #6
            I'm glad you are looking forward to the EL support, and I agree that it makes things much simpler in terms of simple property value to channel mapping. There are some content-based routing cases that do require backing by an implementation however, and often those POJOs might already exist within the application (since we unwrap the payload automatically to invoke, it doesn't require any *new* code being written to handle the Message itself). For example (admittedly contrived):
            Code:
            <router input-channel="employeeIds" ref="hrManager" method="lookupDepartmentForEmployeeId"/>
            
            <channel id="sales"/>
            <channel id="engineering"/>
            ...

            Comment

            Working...
            X