Announcement Announcement Module
Collapse
No announcement yet.
way to pin point the item which failed on write in a chunk Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • way to pin point the item which failed on write in a chunk

    Hello All,

    What are the ways to log exact item which failed during writing a chunk of say 10 items size ?

    Is there a way to catch it in onWriteError method of ItemWriteListener ?
    Is it possible to know this by extending ItemWriter interface ?

    Thanks and Regards,
    Nik

  • #2
    ItemWriter.write() accepts a List of items, so it is impossible in general to know if one of them failed or all of them. If you write you own ItemWriter and it processes each item in turn, of course you can catch exceptions and process them. Otherwise the only way to nail an individual item is with ItemWriteListener. In general there may not even be an item-specific error - it might just be a connectivity problem, or a problem that only arises when all the items are cross-validated.

    Comment


    • #3
      Originally posted by Dave Syer View Post
      ItemWriter.write() accepts a List of items, so it is impossible in general to know if one of them failed or all of them. If you write you own ItemWriter and it processes each item in turn, of course you can catch exceptions and process them. Otherwise the only way to nail an individual item is with ItemWriteListener. In general there may not even be an item-specific error - it might just be a connectivity problem, or a problem that only arises when all the items are cross-validated.
      Thanks for the reply Dave... But ItemWriteListener's onWriteError method also accepts a list of items.. So i don't think it will be possible to pin point the errored item (considering data error only and not some transient error)....

      The only way I see is to implement skipListeners......

      Please correct me if I am wrong or if there is some other way to do this...

      Thanks
      Nik

      Comment


      • #4
        I'm sorry, I was confusing ItemWriteListener with SkipListener. SkipListener is the only way to identify failed items (if they can be identified).

        Comment


        • #5
          way to pin point the item which failed on write in a chunk

          Hello Dave,

          Thanks for the clarification!!

          Regards,
          Nik

          Comment


          • #6
            Depends on what you are writing, but sometimes you can determine the specific item that failed without doing something like using a chunk size of 1. For example, if you are doing Batch inserts/updates with JDBC, you can catch the BatchUpdateException and call the method getUpdateCounts to determine which item failed. There are 2 ways a JDBC driver report the status of the update counts. See the BatchUpdateException javadoc for details.

            Comment

            Working...
            X