From 623158188d233bcc4bc6f9d486b95fb1aed6d870 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Sat, 6 May 2023 14:04:27 +0800 Subject: [PATCH] =?UTF-8?q?//=20=E6=A0=87=E8=AE=B0=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E5=A4=84=E7=90=86,mark=E6=AF=94publish=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=8F=90=E5=89=8D,=E5=B0=BD=E9=87=8F=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E4=BA=8B=E4=BB=B6=E9=87=8D=E5=A4=8D=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- domain/service/event_s/send_gift.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/domain/service/event_s/send_gift.go b/domain/service/event_s/send_gift.go index 9125763..6ebe377 100644 --- a/domain/service/event_s/send_gift.go +++ b/domain/service/event_s/send_gift.go @@ -56,17 +56,17 @@ func (s *GiftSendEventService) Consume() error { model.Log.Errorf("json msg fail,event:%v,err:%v", cpEvent, err) return nil } - if err := gift_ev.PublishSendGiftEvent(model, sendGiftEvent); err != nil { - model.Log.Errorf("PublishSendGiftEvent fail,event:%v,err:%v", string(cpEvent.Payload), err) - return err - } - // 标记已经处理 + // 标记已经处理,mark比publish事件提前,尽量避免异步事件重复执行 cpEvent.Model = model err = cpEvent.MarkDone() if err != nil { model.Log.Errorf("consume msg fail,event:%v,err:%v", cpEvent, err) return err } + if err := gift_ev.PublishSendGiftEvent(model, sendGiftEvent); err != nil { + model.Log.Errorf("PublishSendGiftEvent fail,event:%v,err:%v", string(cpEvent.Payload), err) + return err + } return nil }) } -- 2.22.0