Results 1 to 3 of 3

Thread: Method call based on header value

  1. #1

    Question Method call based on header value

    Hi all!

    I'm currently using spring integration 2.0.0.M5 and looking on the docs I couldn't find how to do something I want to.

    Basically, I'm receiving two different messages on the same channel. One is to create a new customer and the other is to update it's details.

    What I wanted to do is based on a header parameter, i.e. action = create, call a different method on my service activator.

    Something looking like this :
    Code:
        <integration:service-activator id="messageProcesor" header-ref="action" input-channel="inputChannel">
            <integration:filter header-value="create" method="createCustomer"/>
            <integration:filter header-value="update" method="updateCustomer"/>
        </integration:service-activator>
    At the moment I can achieve what I need having a headerValueRouter. Based on the header value, I send the message to a specific channel, say inputCreateChannel or inputUpdateChannel. From that I have a service-activator for each channel but that's making me having lot's of similar service activators.

    Don't know if I was clear but would appreciate any help.

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

    Default

    The approach you describe is the correct one.
    Service activator is a component with responsibility to convert received Message to service method invocation and back to Message (if there is a return value). And when it comes to routing you route Messages (not method invocations), so routing message to to different Service Activators which represent two different services is appropriate and cost nothing.

  3. #3

    Default

    thanks for the clarification

    will keep my approach =)

Posting Permissions

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