handle method
Handle the job context Call next() to continue to the next middleware or job execution
Implementation
@override
Future<void> handle(QueueJobContext context, Next next) async {
int attempt = 0;
while (attempt < maxAttempts) {
try {
await next();
return; // Success, exit
} catch (e) {
attempt++;
context.addMetadata('attempts', attempt);
// Check if we should retry
if (attempt >= maxAttempts) {
rethrow;
}
if (shouldRetry != null && !shouldRetry!(e)) {
rethrow;
}
// Wait before retrying
await Future.delayed(delay * attempt);
}
}
}