extract attempt_retry method in RetryJobs middleware
Merge pull request #1928 from substars/attempt_retry

extract attempt_retry method in RetryJobs middleware