Skip to content

Commit

Permalink
Merge pull request #1867 from HiranyaKavishani/main
Browse files Browse the repository at this point in the history
Adding retry interval logs for every attempt when adapter connection retry happens with control plane
  • Loading branch information
Rajith90 authored Apr 9, 2021
2 parents b49d747 + 42daa16 commit c0c98f6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion adapter/internal/messaging/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ func connectionRetry(key string) (*Consumer, *amqp.Connection, error) {
retryInterval = 10 * time.Second
}
logger.LoggerMsg.Infof("Retrying to connect with %s in every %d seconds until exceed %d attempts",
amqpURIArray[j].url, retryInterval, maxAttempt)
amqpURIArray[j].url, amqpURIArray[j].connectionDelay, maxAttempt)

for i := 1; i <= maxAttempt; i++ {

rabbitConn, err = amqp.Dial(amqpURIArray[j].url + "/")
if err == nil {
if key != "" && len(key) > 0 {
Expand All @@ -85,6 +86,13 @@ func connectionRetry(key string) (*Consumer, *amqp.Connection, error) {
}
return nil, rabbitConn, nil
}

if key != "" && len(key) > 0 {
logger.LoggerMsg.Infof("Retry attempt %d for the %s to connect with topic %s has failed. Retrying after %d seconds", i,
amqpURIArray[j].url, key, amqpURIArray[j].connectionDelay)
} else {
logger.LoggerMsg.Infof("Retry attempt %d for the %s has failed. Retrying after %d seconds", i, amqpURIArray[j].url, amqpURIArray[j].connectionDelay)
}
time.Sleep(retryInterval)
}
if i == maxAttempt {
Expand Down

0 comments on commit c0c98f6

Please sign in to comment.