Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Exception Handling in Spring Batch

Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a spring batch with reader,processor and writer.

Batch starts by reading a message from an external system , processes it and writes it to other folder in the external system. In the writer am checking if there are any more messages in the external system if yes go back to reader else stop the batch job. I want to make sure that only one message at a time is processed.

Now, I want to handle the case when there is an exception in processor while processing a message.
How do I go back to reader to read the next message(and skip the current one) from the external system as the current message has thrown an exception. In case of exception while processing the message I do not want to go to writer as it will delete the message from that place and place it in other folder (all the processed messages will be moved to other folder)

My batch works as below

READER - Read the message from "folder1"
PROCESSOR - Process the message
WRITER - On successful processing, write the message to "folder2" and Delete the message from "folder1"

All the read and successfully processed messages will be deleted from their original folder.

Suggestions please.

Thank you.
Kishen Singh Punjabi
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am using in the chunk and its skipping the messages with exception for that moment and carrying on with other messages.

Any other approaches ??
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic