提交 f256b7f9 authored 作者: 张立波's avatar 张立波

消息

上级 9963f94c
...@@ -41,12 +41,8 @@ func InitProducer(config *NsqConfig) *NsqProducer { ...@@ -41,12 +41,8 @@ func InitProducer(config *NsqConfig) *NsqProducer {
//发布消息 //发布消息
func (p *NsqProducer) Publish(topic string, message string) (err error) { func (p *NsqProducer) Publish(topic string, message string) (err error) {
defer func() {
if err != nil {
//重试连接 //重试连接
InitProducer(nsqConfig) NsqProducers = InitProducer(nsqConfig)
}
}()
if p.producer != nil { if p.producer != nil {
if message == "" { //不能发布空串,否则会导致error if message == "" { //不能发布空串,否则会导致error
...@@ -67,8 +63,7 @@ func (p *NsqProducer) Publish(topic string, message string) (err error) { ...@@ -67,8 +63,7 @@ func (p *NsqProducer) Publish(topic string, message string) (err error) {
//发布延迟消息 //发布延迟消息
func (p *NsqProducer) DeferredPublish(topic string, delay time.Duration, message string) error { func (p *NsqProducer) DeferredPublish(topic string, delay time.Duration, message string) error {
//logs.Infof(context.Background(),"topic",message) NsqProducers = InitProducer(nsqConfig)
var err error var err error
if p.producer != nil { if p.producer != nil {
if message == "" { //不能发布空串,否则会导致error if message == "" { //不能发布空串,否则会导致error
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论