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
768 stars 125 forks source link

How to resend a message when it fails to send #86

Closed yeyudekuangxiang closed 1 year ago

yeyudekuangxiang commented 2 years ago

How to resend a message when it fails to send

BowlOfSoup commented 2 years ago

Can you provide a bit more context? What do you mean with "fails to send"? Are there error messages?

yeyudekuangxiang commented 2 years ago

sorry,i mean i want to call channel.GetNextPublishSeqNo() method before sending message

seqNo := channel.GetNextPublishSeqNo()
        Log.Printf("publishing %dB body (%q)", len(body), body)

        if err := channel.Publish(
            exchange,   // publish to an exchange
            routingKey, // routing to 0 or more queues
            false,      // mandatory
            false,      // immediate
            amqp.Publishing{
                Headers:         amqp.Table{},
                ContentType:     "text/plain",
                ContentEncoding: "",
                Body:            []byte(body),
                DeliveryMode:    amqp.Transient, // 1=non-persistent, 2=persistent
                Priority:        0,              // 0-9
                // a bunch of application/implementation-specific fields
            },
        ); err != nil {
            return fmt.Errorf("Exchange Publish: %s", err)
        }
wagslane commented 1 year ago

This looks like a question for the AMQP lib