Skip to content
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

feat: MQ redelivery with backoff and maximum attempts #851

Merged
merged 1 commit into from
Nov 1, 2021

Conversation

bstasyszyn
Copy link
Contributor

@bstasyszyn bstasyszyn commented Oct 29, 2021

Two new queues are added: redelivery and wait.

The 'redelivery' queue is configured as the 'dead-letter-queue' for all queues in Orb. When a message is rejected by a subscriber, it is automatically sent to the 'redelivery' queue. The first time a message is rejected, the redelivery handler immediately redelivers the message to the original destination queue. If the message is rejected again, it is posted to a 'wait' queue and is given an expiration. The 'wait' queue has no subscribers, so the message will sit there until it expires.

The 'redelivery' queue is also configured as the 'dead-letter-queue' for the 'wait' queue, so when the message expires, it is automatically sent back to the 'redelivery' queue and this handler processes the message again. If the message metadata, 'reason', is set to "expired" then it is posted to the original destination queue, otherwise (if reason is "rejected") it is posted back to the 'wait' queue with a bigger expiration. This process repeats until the maximum number of redelivery attempts has been reached, at which point redelivery for the message is aborted.

This PR also fixes some BDD tests that failed because of timing.

closes #803

Signed-off-by: Bob Stasyszyn Bob.Stasyszyn@securekey.com

@cla-bot cla-bot bot added the cla-signed label Oct 29, 2021
@codecov
Copy link

codecov bot commented Oct 29, 2021

Codecov Report

Merging #851 (319fb43) into main (4214278) will decrease coverage by 0.08%.
The diff coverage is 85.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #851      +/-   ##
==========================================
- Coverage   89.47%   89.38%   -0.09%     
==========================================
  Files         147      148       +1     
  Lines       12846    13125     +279     
==========================================
+ Hits        11494    11732     +238     
- Misses        831      855      +24     
- Partials      521      538      +17     
Impacted Files Coverage Δ
pkg/activitypub/service/service.go 93.65% <ø> (ø)
pkg/anchor/vcpubsub/publisher.go 100.00% <ø> (ø)
pkg/context/opqueue/opqueue.go 100.00% <ø> (ø)
pkg/pubsub/amqp/marshaler.go 77.27% <77.27%> (ø)
pkg/pubsub/amqp/amqppubsub.go 92.16% <89.50%> (-4.86%) ⬇️
...event/generator/didorbgenerator/didorbgenerator.go 83.49% <100.00%> (ø)
pkg/observer/pubsub.go 94.49% <100.00%> (+0.05%) ⬆️
pkg/store/witness/witness.go 89.47% <0.00%> (+0.35%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a85fda8...319fb43. Read the comment docs.

Two new queues are added: redelivery and wait.

The 'redelivery' queue is configured as the 'dead-letter-queue' for all queues in Orb. When a message is rejected by a
subscriber, it is automatically sent to the 'redelivery' queue. The first time a message is rejected, the redelivery handler
immediately redelivers the message to the original destination queue. If the message is rejected again, it is posted to a
'wait' queue and is given an expiration. The 'wait' queue has no subscribers, so the message will sit there until it expires.
The 'redelivery' queue is also configured as the 'dead-letter-queue' for the 'wait' queue, so when the message expires, it is
automatically sent back to the 'redelivery' queue and this handler processes the message again. If the message metadata,
'reason', is set to "expired" then it is posted to the original destination queue, otherwise (if reason is "rejected") it is
posted back to the 'wait' queue with a bigger expiration. This process repeats until the maximum number of redelivery attempts
has been reached, at which point redelivery for the message is aborted.

closes trustbloc#803

Signed-off-by: Bob Stasyszyn <Bob.Stasyszyn@securekey.com>
@fqutishat fqutishat merged commit 4909584 into trustbloc:main Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement "max-retries" for AMQP
3 participants