Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support for passing a function to terminateVisibilityTimeout #1

Merged
merged 4 commits into from
Dec 18, 2024

Conversation

lucleray
Copy link
Member

Allow to pass a function to terminateVisibilityTimeout

It allows to easily add a retry strategy with exponential backoff and/or jitter.

For example:

consumer = new Consumer({
  [...]
  terminateVisibilityTimeout: (message: SQSMessage) => {
    const retryCount = Number.parseInt(message.Attributes?.ApproximateReceiveCount) || 1;
    return 
      5 ** retryCount  + // exponential backoff
      Math.random() * 60; // jitter
  }
});

@lucleray lucleray merged commit c92a5c7 into master Dec 18, 2024
2 checks passed
@lucleray lucleray deleted the visibility-timeout-exponential-jitter branch December 18, 2024 10:37
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants