-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added exponential delay for poisoned message handlers #175
Conversation
class ExponentialDelay(initialDelay: Duration, period: Duration, factor: Double, maxLength: Duration) { | ||
private val maxMillis = maxLength.toMillis | ||
|
||
def getExponentialDelay(attempts: Int): FiniteDuration = { | ||
if (attempts == 0) FiniteDuration(initialDelay._1, initialDelay._2) | ||
else { | ||
val millis = math.min( | ||
maxMillis, | ||
(period.toMillis * math.pow(factor, attempts - 1)).toLong | ||
) | ||
FiniteDuration(millis, TimeUnit.MILLISECONDS) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ExponentialDelay(initialDelay: Duration, period: Duration, factor: Double, maxLength: Duration) { | |
private val maxMillis = maxLength.toMillis | |
def getExponentialDelay(attempts: Int): FiniteDuration = { | |
if (attempts == 0) FiniteDuration(initialDelay._1, initialDelay._2) | |
else { | |
val millis = math.min( | |
maxMillis, | |
(period.toMillis * math.pow(factor, attempts - 1)).toLong | |
) | |
FiniteDuration(millis, TimeUnit.MILLISECONDS) | |
} | |
} | |
} | |
class ExponentialDelay(initialDelay: Duration, period: Duration, factor: Double, maxLength: Duration) { | |
private val maxMillis = maxLength.toMillis | |
def getExponentialDelay(attempt: Int): FiniteDuration = { | |
if (attempt == 0) FiniteDuration(initialDelay._1, initialDelay._2) | |
else { | |
val millis = math.min( | |
maxMillis, | |
(period.toMillis * math.pow(factor, attempt - 1)).toLong | |
) | |
FiniteDuration(millis, TimeUnit.MILLISECONDS) | |
} | |
} | |
} |
# Conflicts: # core/src/main/scala/com/avast/clients/rabbitmq/PoisonedMessageHandler.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In overall, it looks good.
I have only two problems:
- Default republish delays - 5 seconds is a weird value :-D But this is not a blocker, if you insist. I'd use just 2 seconds instead ;-)
- The functionality is not tested. I believe it should be a part of some test case in
PoisonedMessageHandlerTest
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!
Added optional exponential delay for republishing messages.