Results 1 to 6 of 6

Thread: Advice for channels configuration

  1. #1

    Default 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. #2
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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

  3. #3

    Default

    Hey Mark,

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

    S.

  4. #4
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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

  5. #5

    Exclamation

    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?

  6. #6
    Join Date
    Jul 2009
    Location
    Charlotte, NC
    Posts
    131

    Default

    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"/>

Posting Permissions

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