Skip to content

Commit

Permalink
fix: fix producer send msg timeout option does not take effect
Browse files Browse the repository at this point in the history
  • Loading branch information
twz915 committed Nov 27, 2023
1 parent c9e197c commit 0a329cc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions producer/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (p *defaultProducer) sendSync(ctx context.Context, msg *primitive.Message,
producerCtx.MQ = *mq
}

res, _err := p.client.InvokeSync(ctx, addr, p.buildSendRequest(mq, msg), 3*time.Second)
res, _err := p.client.InvokeSync(ctx, addr, p.buildSendRequest(mq, msg), p.options.SendMsgTimeout)
if _err != nil {
err = _err
continue
Expand Down Expand Up @@ -400,7 +400,7 @@ func (p *defaultProducer) sendAsync(ctx context.Context, msg *primitive.Message,
return errors.Errorf("topic=%s route info not found", mq.Topic)
}

ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
ctx, cancel := context.WithTimeout(ctx, p.options.SendMsgTimeout)
err := p.client.InvokeAsync(ctx, addr, p.buildSendRequest(mq, msg), func(command *remote.RemotingCommand, err error) {
cancel()
if err != nil {
Expand Down Expand Up @@ -465,7 +465,7 @@ func (p *defaultProducer) sendOneWay(ctx context.Context, msg *primitive.Message
return fmt.Errorf("topic=%s route info not found", mq.Topic)
}

_err := p.client.InvokeOneWay(ctx, addr, p.buildSendRequest(mq, msg), 3*time.Second)
_err := p.client.InvokeOneWay(ctx, addr, p.buildSendRequest(mq, msg), p.options.SendMsgTimeout)
if _err != nil {
err = _err
continue
Expand Down

0 comments on commit 0a329cc

Please sign in to comment.