|
|
|
@ -50,15 +50,14 @@ func (o rabbitMq) ListenRetry(queue string, count int, handler func([]byte) erro
|
|
|
|
|
for {
|
|
|
|
|
select {
|
|
|
|
|
case e := <-notifyClose:
|
|
|
|
|
num := count - 1
|
|
|
|
|
if num <= 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
log.Printf("chan通道错误, e: %s. 还有%d重试机会\n", e.Error(), count)
|
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
|
count += 1
|
|
|
|
|
log.Printf("chan通道错误, e: %s. 还有第%d次重试\n", e.Error(), count)
|
|
|
|
|
close(closeChan)
|
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
|
go o.ListenRetry(queue, num, handler)
|
|
|
|
|
go o.ListenRetry(queue, count, handler)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
case v := <-d:
|
|
|
|
|
if err = handler(v.Body); err != nil {
|
|
|
|
|
log.Printf("%s:%s\n", queue, err.Error())
|
|
|
|
|