Delivery Confirmation¶
Delivery confirmation allows a publisher to verify that RabbitMQ accepted a message.
Use it when message loss is not acceptable.
Publish Flow¶
sequenceDiagram
participant Publisher
participant RabbitMQ
Publisher->>RabbitMQ: Publish message
RabbitMQ-->>Publisher: Ack / Nack
Descriptor¶
var descriptor = new PublisherBoundDescriptor
{
Confirmation = new DeliveryConfirmation
{
Enabled = true,
WaitFor = true,
Timeout = TimeSpan.FromSeconds(30)
},
Exchanges =
{
new ExchangeBoundDescriptor
{
Name = "orders",
Type = ExchangeTypes.Direct,
Durable = true
}
}
};
Retry Hook¶
publisher.OnRetryFailed.Add(async args =>
{
// Log or persist the failed publish attempt.
await Task.CompletedTask;
});
When To Use¶
Enable delivery confirmation when:
- messages are business critical;
- auditability is required;
- publishing failures must be detected;
- the caller must know whether RabbitMQ accepted the message.
Trade-Offs¶
| Benefit | Cost |
|---|---|
| Better reliability | Lower throughput |
| Failure visibility | Extra latency |
| Stronger publish guarantees | More broker coordination |
Delivery confirmation should be enabled deliberately, especially in high-throughput publishers.