watermill icon indicating copy to clipboard operation
watermill copied to clipboard

Retry Middleware blocked message

Open guihouchang opened this issue 2 years ago • 2 comments

When I use a single consumer, subsequent messages cannot be consumed normally after Retry is triggered.

retryLoop:
		for {
			waitTime := expBackoff.NextBackOff()
			select {
			case <-ctx.Done():
				return producedMessages, err
			case <-time.After(waitTime):
				// go on
			}

			producedMessages, err = h(msg)
			if err == nil {
				return producedMessages, nil
			}

			if r.Logger != nil {
				r.Logger.Error("Error occurred, retrying", err, watermill.LogFields{
					"retry_no":     retryNum,
					"max_retries":  r.MaxRetries,
					"wait_time":    waitTime,
					"elapsed_time": expBackoff.GetElapsedTime(),
				})
			}
			if r.OnRetryHook != nil {
				r.OnRetryHook(retryNum, waitTime)
			}

			retryNum++
			if retryNum > r.MaxRetries {
				break retryLoop
			}
		}

guihouchang avatar Mar 03 '22 09:03 guihouchang

Do you mean after entering retryLoop section?

checkmunza avatar Mar 05 '22 08:03 checkmunza

yes, when I set InitialInterval 30min, it causes message blocking

guihouchang avatar Mar 07 '22 10:03 guihouchang

@guihouchang if you set the initial interval to 30 minutes, the middleware waits for 30 minutes after a message processing fails. This is by design, and it blocks further messages. If you need to unblock the following messages, you need something more complex, like publishing the broken message on a poison queue.

m110 avatar Jan 21 '23 16:01 m110