@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface Recovery
Recovery strategies help maintain system consistency during failures by defining clear policies for handling transient vs. permanent errors.
Example usage:
@Recovery(strategy = RecoveryStrategy.ALWAYS_RETRY)
@Change(id = "populate-cache", order = "2024-11-18-001", author = "cache-team")
public class PopulateCacheChange {
@Apply
public void populateCache(CacheManager cache, ExternalAPI api) {
// Might fail due to transient network issues - safe to retry
cache.put("data", api.fetchData());
}
}
@Recovery(strategy = RecoveryStrategy.MANUAL_INTERVENTION)
@Change(id = "critical-data-migration", order = "2024-11-18-002", author = "data-team")
public class CriticalDataMigration {
@Apply
public void migrateData(Database db) {
// Complex migration requiring human verification on failure
db.executeMigration();
}
}
Change,
RecoveryStrategy| Modifier and Type | Optional Element and Description |
|---|---|
RecoveryStrategy |
strategy
The recovery strategy to apply when this change fails.
|
public abstract RecoveryStrategy strategy
RecoveryStrategy.MANUAL_INTERVENTION for safety.