0

I am developing a Spring Batch App -

How to understand or write code for ?

  1. Identify which chunk has failed in chunk based step?
  2. How to identify if reader query taking how much time?
PAA
  • 1
  • 46
  • 174
  • 282

1 Answers1

0
  1. Identify which chunk has failed in chunk based step?

A ChunkListener allows you to achieve that. The method afterChunkError will be called when an error occurs in a given chunk

  1. How to identify if reader query taking how much time?

It depends on the reader. ItemReadListener is called around each read operation, which is not where the query is typically called. For example, the JdbcCursorItemReader executes the query in openCursor method. This method is protected, you can override it and time it as needed. For the JdbcPagingItemReader, the query for each page is called in the doReadPage method, which is also protected, so you can override it and time it as needed.

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50
  • Thanks for the reply, is there any way if we can get the chunk number or which item is garbage data? – PAA Feb 10 '21 at 13:37
  • For chunk number, no, you need to keep a counter in your chunk listener. For invalid items, yes, you could use a `SkipListener` for skipped items during read/process/write phases. – Mahmoud Ben Hassine Feb 10 '21 at 16:21
  • Thanks for the reply. I think we should give facility to access the chunk no. this really help to find exact chunk and then lowering down chunk size could get the value too – PAA Feb 10 '21 at 16:59
  • That's another feature, you can open an issue if you want. For this question, I believe I answered it. So please accept/upvote the answer or let me know if you need other details. – Mahmoud Ben Hassine Feb 11 '21 at 07:37