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()
}
Channel did not close properly after publishing a message. They are all stacked in
idle
state. In my code, I did usepuber.close()
to close the publisher.