Announcement Announcement Module
No announcement yet.
Multiline reader Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiline reader

    In every example I see in for multiline readers, the reader stops when it encounters a footer line. My problem is the "footer line" is only a footer line based on value of the next line. I can't know the next line without calling read() on the delegate reader. Is there something in the Spring Batch API that I can use to implement a look ahead feature?

    Thanks in advance. I can post pseudo-code if it makes it easier to illustrate what I'm talking about.

  • #2
    It's easy to write a peekable ItemReader as a wrapper for another one , but you lose restartability unless you are careful (and all the projects I know that did this didn't care about restartability). I started a JIRA


    • #3
      Thanks Dave. As you surmised, restartability is not priority number one so I'll take a stab at wrapping a peekable writer.

      Any words to wise with respect to restartability that I should keep in mind?
      Last edited by mkreis1; Jul 29th, 2009, 08:42 AM. Reason: mis typed


      • #4
        Restartability means implementing ItemStream. If your delegate reader implements ItemStream already then you are half way there, but you have to be careful that if you have peeked, the result of that peek doesn't get into the ExecutionContext in an ItemStream.update(). Remember also that an ItemReader is forward-only, so once you peek you have to buffer the peeked item for the next read(). Together that means you have to buffer the item count as well and only increment on read() of your wrapper, not of the wrapped delegate reader.