Announcement Announcement Module
No announcement yet.
apply processor on several items instead of one Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • apply processor on several items instead of one

    Hi all,

    In one of my batch, i need to call a web-service to enrich some data from an item read in db, check some values and then write this enrich item into another table.
    My web-service can support several requests in the same call in order to minimize the number of calls to the web-service. Actually my web-service call is defined as a processor:
    <batch:tasklet task-executor="taskExecutor">
      <batch:chunk reader="bookingReader" processor="bookingEnrichWSProcessor"
        writer="bookingCompositeWriter" commit-interval="10" />
    It seems that only the item writer can support writing several items in one call using property commit-interval in the step definition.

    What i need is to read items ten by ten with the reader, and call the ws with the 10 items before wirting them again in another table.

    Is it possible to do that in a processor class? or should i port this logic in a writer.

    Thanks for our help
    Last edited by ekki77; Jul 26th, 2012, 03:05 AM. Reason: bad sentence

  • #2
    From my knowledge of Spring Batch, processor will always receive a single element.
    See the section 5.1. Chunk-Oriented Processing
    List items = new Arraylist();
    for(int i = 0; i < commitInterval; i++){
        Object item =
        Object processedItem = itemProcessor.process(item);
    Maybe If your reader returns a List<List<Books>> the processor will receive a List<Books>? Just guessing here, but I think it'll work.
    Last edited by traduz; Jul 26th, 2012, 09:11 AM.