Skip to content

Commit 64c87a0

Browse files
authored
[Fix][Producer] Reconnection backoff logic for producer (#1125)
Co-authored-by: gunli <[email protected]>
1 parent 0845e73 commit 64c87a0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pulsar/producer_partition.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,18 @@ func (p *partitionProducer) reconnectToBroker() {
396396
maxRetry = int(*p.options.MaxReconnectToBroker)
397397
}
398398

399+
var (
400+
delayReconnectTime time.Duration
401+
defaultBackoff = internal.DefaultBackoff{}
402+
)
403+
399404
for maxRetry != 0 {
400405
if p.getProducerState() != producerReady {
401406
// Producer is already closing
402407
p.log.Info("producer state not ready, exit reconnect")
403408
return
404409
}
405410

406-
var (
407-
delayReconnectTime time.Duration
408-
defaultBackoff = internal.DefaultBackoff{}
409-
)
410-
411411
if p.options.BackoffPolicy == nil {
412412
delayReconnectTime = defaultBackoff.Next()
413413
} else {

0 commit comments

Comments
 (0)