0

Is there any listener interface that one could implement to handle exceptions thrown from ItemReader.open() methods? There's plenty of listener interfaces but no one seems to be suitable for this. i.e. ItemReadListener catches only exceptions from ItemReader.readItem() (similar to ChunkListener or ItemProcessListener etc.)

There are JobListener and StepListener interfaces but these two don't define methods that would be called in case of exception.

Is there any way how to do this?

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40
bambula
  • 365
  • 1
  • 12

1 Answers1

0

You may be able to use ChunkListener#onError(Exception e) to "catch" any exception within a chunk. This will work in certain implementations, like WebSphere Liberty / Open Liberty, but may not work in every implementation (since this was a grey area of the specification).

Scott Kurz
  • 4,985
  • 1
  • 18
  • 40
  • `ItemReader.open()` is out of the scope of ChukListener. If I understand the concept correctly `open()` is called before the chunks are performed. However `ChukListener.onError()` doesn't catch the excpetion. At least in the JBeret implementation of JSR352 – bambula Feb 26 '19 at 16:02
  • I see. I work on WebSphere Liberty Batch, where we do call the ChunkListener here. But in fairness to JBeret, there was certainly room for interpretation of the spec requirements here, and I'm not surprised if they implemented it differently. I tagged this with `jberet` in case that helps. – Scott Kurz Feb 26 '19 at 16:12
  • Can you elaborate on your use case, and for what purpose you want to handle that exception? I'd like to better understand it to figure out how to address it in JBeret. – cheng Feb 26 '19 at 21:00