I’ve a batch job that loops through a bunch of records and processes them. During the processing multiple levels of classes are invoked before invoking an external service. This service is sometimes down for extended periods of time. I can code for a timeout situation, trap the exception using a try/catch block, and act upon it.
I want to stop the processing immediately when the first timeout occurs. The only way I can think of doing it is bubbling up the error all the way to the loop logic in the top class and issuing a break statement so no further records are processed.
Is there a better way to stop the processing immediately at the lowest level without bubbling up?
Thanks.