wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
772 stars 126 forks source link

How to publish with confirms #40

Closed ofttryaj closed 2 years ago

ofttryaj commented 2 years ago
confirms := make(chan amqp.Confirmation)
ch.NotifyPublish(confirms)
go func() {
    for confirm := range confirms {
        if confirm.Ack {
            // code when messages is confirmed
            log.Printf("Confirmed")
        } else {
            // code when messages is nack-ed
            log.Printf("Nacked")
        }
    }
}()
pete-woods commented 2 years ago

This feels like the only significant missing feature for me, from this library.

wagslane commented 2 years ago

It's a good point, I've been biased by my personal use-cases for rabbit a little bit here, I'm totally open to PRs though to add the feature!

pete-woods commented 2 years ago

For what it's worth (probably not what you want to hear), I ended up using this library, which does offer publisher confirms: https://github.com/makasim/amqpextra

wagslane commented 2 years ago

Good feedback, I'm merging this feature today