0

I am using Spring Batch 2.1.8.RELEASE. I have a file which consists of some Header information followed by some records which I need to process.

I have a step which makes use of chunk oriented processing. The step contains an implementation of the ItemReader and ItemWriter. The ItemReader implementation is thread-safe while the ItemWriter is not.

I want to use the Header information before I process( or write) any of the records. How do I ensure this while continuing to use the chunk oriented processing?

Proposed Solution : One solution could be to write a pre-process step and extract the header information.

Is there any alternate solution to this?

Thanks

1 Answer 1

1

You can try an approch similar to one describer in Spring Batch Item Reader - use skippedLinesCallback to set input field names : you must inject the headerCallback bean into your reader (and processor or writer) and use it safely because the headerCallback bean has been called from your reader.

I hope I was clear, English is not my native language (and I'm in troubles with past tenses '-_-)

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot bellabax, but just to clarify the question, I have a multi-line header. Also,I have set the throttle-limit > 1 for scalibilty, in that case, how can I ensure that the chunk containing the header is processed (or written) before any other chunk ?
I don't know this specific behaviour,but for FlatFileItemReader the skipLines property is managed before all next read and should works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.