Sonam,
Your approach is almost perfect. That is the correct way to handle scenarios that require indefinite retries.
The answer to your question about why the throwExceptionForRetry cannot be called from the catch block :
The catch block, unlike a java catch block, is a sequence with an EXIT setting. The setting for the catch block is usually “EXIT on DONE” or “EXIT on FAILURE”. So if it is the former then any exception in the block will be suppressed. That means your Exception for retry is lost. If it is the latter then the SEQUENCE wraps the exception into a FlowException and throws that. That would mean that your retriable(is that even a word ?) Exception just became non-retriable.
So what you are doing is the only way to use the throwExceptionForRetry service.
Off course, you do want to be careful with what constitutes a forever retry otherwise you can end up with a document stuck in the queue forever. If there is reason for you to doubt the way the adapter service throws a transient or non transient exception you can use your own logic but then you can end with a forever loop.
I do rememeber needing something to determine whether an exception thrown from a service is transient or not because some of the children flows had adapter services in catch blocks which wrapped up the exception. The code for that service is now in PSUtilities and is called ps.util.system:getExceptionType.
It works because the ART will throw a com.wm.pkg.art.error.DetailedSystemException on a transient error. If the lastError structure has that pattern you can kind of unwrap it by throwing a runtime exception.
Hope I clarified the situation somewhat and did not add to the confusion.
Rupinder
#Flow-and-Java-services#webMethods#Integration-Server-and-ESB