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
805 stars 128 forks source link

Exception (504) Reason: "channel id space exhausted" #102

Closed anxuanzi closed 1 year ago

anxuanzi commented 1 year ago

Channel did not close properly after publishing a message. They are all stacked in idle state. In my code, I did use puber.close() to close the publisher.

// PushMsg pushes a message to the message queue
func PushMsg(queueName string, m any) {
    data, err := json.Marshal(m)
    if err != nil {
        slog.Error(err)
        return
    }
    puber, err := rabbitmq.NewPublisher(wmqInstance.mqConnection,
        rabbitmq.WithPublisherOptionsLogger(slog.NewStdLogger()),
        rabbitmq.WithPublisherOptionsLogging,
    )
    if err != nil {
        slog.Error(err)
        return
    }
    err = puber.Publish(data, []string{queueName},
        rabbitmq.WithPublishOptionsMandatory,
        rabbitmq.WithPublishOptionsPersistentDelivery,
        rabbitmq.WithPublishOptionsExchange("amq.direct"))
    if err != nil {
        slog.Error(err)
        return
    }
    puber.Close()
}
xwrs commented 1 year ago

same issue here. seems that channel created here

is never closed