Announcement Announcement Module
Collapse
No announcement yet.
Advice for channels configuration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Advice for channels configuration

    I have a quite simple application and I am trying to integrate it with Spring integration. The most important feature is the fine grain control over the number of consumers handling a message because the system can be quite heavily loaded.

    I basically have 4 services:

    1. A service (S1) that grabs a media from an HTTP url (an image for instance) and sends a response R
    2. A service (S2), based on a document, that gets the URLs to grab
    3. A service (S3), based on the same document, that gets another URL to grab
    4. A service (S4) that take a response R and updates the database with some meta data

    I tried to decouple these services as much as possible so that they can be tested separately.

    The flow is quite simple:

    1. A new document is made available so an "Incoming document event" is posted on a channel
    2. Service S2 and S3 analyze the document and generate a set of request for S1. These requests must be sent to S1
    3. S1 processes each request and send a response for each of them (R)
    4. R processes the response and update the database

    What is the best approach to configure this with Spring integration? Namely, I'd like not to use messageChannel.send(msg) in S2 and S3. Initially I though I could simply return the request and it will be routed using the output channel but one of my service can generate X requests (not only one).

    Besides, each of these analysis can potentially hit the network so I want to isolate them to improve the overral performance.

    Thanks,
    Stéphane

  • #2
    If each of your service implementations is referenced from a <service-activator>, then the framework will handle all the send/receive operations for you. In terms of the multiple responses, if you pass a Collection result through a <splitter>, the downstream handler will receive each entry.

    HTH,
    Mark

    Comment


    • #3
      Hey Mark,

      Thanks for the quick response. Yep, I thought splitter would help. Do you have a sample usage somewhere?

      S.

      Comment


      • #4
        Sure, the 'cafe' sample has a splitter. You can find it in the 'applications/cafe' directory within the samples repository: http://git.springsource.org/spring-integration/samples

        Also, the reference manual is probably sufficient, since <splitter> is rather straightforward. For detail, see here: http://static.springsource.org/sprin...ngle/#splitter

        Comment


        • #5
          Well, either I need more coffee or I described my problem too vaguely

          Here is my config

          Code:
          <int:service-activator input-channel="documentUrlsProcessorChannel"
                                     output-channel="mediaRetrievalRequestChannel"
                                     ref="documentUrlsProcessor">
                  <int:poller task-executor="documentUrlsProcessorTaskExecutor"
                              fixed-rate="200" max-messages-per-poll="50"/>
              </int:service-activator>
          What I would like is that documentUrlsProcessor returns a list of MediaRetrievalRequest and then SI would send one message per item in the list in the "mediaRetrievalRequestChannel" (the output channel).

          I tried this but it didn't worked

          Code:
          @ServiceActivator
          @Transactional
          @Splitter
          public List<MediaRetrievalRequest> handle(Document doc) {
            ...
          }
          I tried to use the splitter with xml but I can't see any sample that does what I want. The café sample takes the content of an input channel and dispatch it to an output channel. That's not what I am doing. What I want is to split the response of my message handler. Do I have to create a channel in between to achieve this?

          Comment


          • #6
            Try something like this.

            <int:service-activator input-channel="documentUrlsProcessorChannel"
            output-channel="splitterChannel"
            ref="documentUrlsProcessor">
            <int: poller task-executor="documentUrlsProcessorTaskExecutor"
            fixed-rate="200" max-messages-per-poll="50"/>
            </int:service-activator>

            <int:splitter id="mySplitter" input-channel="splitterChannel"
            output-channel="mediaRetrievalRequestChannel"/>

            Comment

            Working...
            X