Skip to content

dead letter handler should reject messages on failures and rollbacks and ack on commit success #105

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

Merged
merged 4 commits into from
Jul 22, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions gbus/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,22 +236,28 @@ func (worker *worker) invokeDeadletterHandler(delivery amqp.Delivery) {
if txCreateErr != nil {
worker.log().WithError(txCreateErr).Error("failed creating new tx")
worker.span.LogFields(slog.Error(txCreateErr))
_ = worker.ack(delivery)
_ = worker.reject(true, delivery)
return
}
var fn func() error
err := worker.deadletterHandler(tx, delivery)
var reject bool
if err != nil {
worker.log().WithError(err).Error("failed handling deadletter")
worker.span.LogFields(slog.Error(err))
fn = tx.Rollback
err = worker.SafeWithRetries(tx.Rollback, MaxRetryCount)
reject = true
} else {
fn = tx.Commit
err = worker.SafeWithRetries(tx.Commit, MaxRetryCount)
}
err = worker.SafeWithRetries(fn, MaxRetryCount)

if err != nil {
worker.log().WithError(err).Error("Rollback/Commit deadletter handler message")
worker.span.LogFields(slog.Error(err))
reject = true
}

if reject {
_ = worker.reject(true, delivery)
}
}

Expand Down