From 1335f6aa645df68134e1df4a1778eb58951b88ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=B0=91=E5=9D=A4?= Date: Thu, 17 Mar 2022 14:27:18 +0800 Subject: [PATCH] fix one chan block --- producers/producer.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/producers/producer.go b/producers/producer.go index da0abb8..992dabc 100644 --- a/producers/producer.go +++ b/producers/producer.go @@ -73,9 +73,10 @@ func (p *Producer) Producer(m *msg.Message, opts ...ProducerOption) { opt(p) } ch := m.Channel - ch.SetConfirmChan(ch.ConfirmOne(make(chan amqp.Confirmation, 1))) - ch.SetReturnChan(ch.NotifyReturn(make(chan amqp.Return, 1))) - //defer ch.Close() + if ch.GetConfirmChan() == nil { + ch.SetConfirmChan(ch.ConfirmOne(make(chan amqp.Confirmation, 1))) + ch.SetReturnChan(ch.NotifyReturn(make(chan amqp.Return, 1))) + } exchangeNum := 0 queueNum := 0 body := string(m.Body)