Conversation
Invalid messages (bad JSON, non-object data, missing or unconfigured topic) fail the same way on every delivery, so on RabbitMQ and Azure Service Bus they are rejected on the first failure instead of requeued. PUBLISH_MAX_REDELIVERIES optionally caps redeliveries of transient failures there, counted in Redis on the failure path only. Reject: RabbitMQ nacks without requeue (dead-letter exchange if set), Azure Service Bus dead-letters. SQS and Pub/Sub keep nacking and rely on their own redrive or dead-letter policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An unconfigured topic is fixed by adding it to TOPICS, so it goes back on the queue and counts toward PUBLISH_MAX_REDELIVERIES instead of being rejected. Rejection errors carry the message ID, since without a dead-letter exchange the log is the only record. Docs note RabbitMQ 4.x quorum queue and Azure Service Bus native delivery limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Past PUBLISH_MAX_REDELIVERIES, SQS and Pub/Sub messages are acked, since they have no reject; invalid messages there count toward the cap instead of looping. The default becomes -1 (unlimited) so 0 can mean no redeliveries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stops publish queue messages from looping forever.
publishmqnacks every handler error, and RabbitMQ requeues on nack, so a malformed message is redelivered in a tight loop and never reaches the queue's dead-letter exchange.Two changes:
datathat is not a JSON object, missingtopicwhenTOPICSis set) are rejected on the first failure.PUBLISH_MAX_REDELIVERIES(opt-in) caps redeliveries of any failed message.Behavior
nack(requeue=false): dead-lettered if the queue has a DLX, discarded otherwisetopicmissing fromTOPICSstays a normal failure, since adding the topic fixes it (e.g. mid rolling deploy).maxReceiveCount/max_delivery_attemptsno higher than the cap, so the broker dead-letters first. A broker-side limit also applies on RabbitMQ (quorumx-delivery-limit) and Azure (MaxDeliveryCount); the lower limit fires first.Counter
Failures only: one pipelined
INCR+EXPIRE(24h) on{deployment_id}:publishmq:failures:{message id}. When the message has no ID, the key uses a hash of the body. If Redis errors, the message is nacked, so a Redis outage never drops messages. The count is not reset on success, to keep Redis off the success path.Heads-up
Nackalways requeues, soRejectnacks the rawamqp091.DeliveryviaAsand clears gocloud's "never acked" finalizer (internal/mqs/queue_rabbitmq.go). Azure dead-letters through the same receiver gocloud settles with.MessageId, since gocloud'sLoggableIDfalls back to the delivery tag, which changes on every redelivery.Tests
TestIntegrationMQ_RabbitMQReject: a rejected message lands in the DLX queue and is not redelivered.TestMessageHandler_MaxRedeliveries*: rejected (or acked on SQS/Pub/Sub) on the Nth redelivery, and still nacked when the counter errors.🤖 Generated with Claude Code