Announcement Announcement Module
No announcement yet.
Advice for channels configuration Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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.


  • #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.



    • #3
      Hey Mark,

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



      • #4
        Sure, the 'cafe' sample has a splitter. You can find it in the 'applications/cafe' directory within the samples repository:

        Also, the reference manual is probably sufficient, since <splitter> is rather straightforward. For detail, see here:


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

          Here is my config

          <int:service-activator input-channel="documentUrlsProcessorChannel"
                  <int:poller task-executor="documentUrlsProcessorTaskExecutor"
                              fixed-rate="200" max-messages-per-poll="50"/>
          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

          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?


          • #6
            Try something like this.

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

            <int:splitter id="mySplitter" input-channel="splitterChannel"