Sometimes, exceptions are thrown due to unexpected outages or so-called hiccups. It is not an uncommon scenario for a system that is highly integrated with other systems or services. For example, the trading system in a stock exchange may need to publish trade execution data to a messaging system for downstream processing. But if the messaging system experiences just a momentary outage, then the operation could fail. In that case, the most common approach is to sleep for a while and then come back and try again. If the retry fails again, then the operation will be retried again later, until the system fully recovers.
Such retry logic is not difficult to write. Here, we will play with an example. Suppose that we have a ...