From 8e02f6f70d8de622641f6c9829eb28ab0febcc8c Mon Sep 17 00:00:00 2001 From: hiranya Date: Thu, 8 Apr 2021 13:39:42 +0530 Subject: [PATCH 1/2] Improving retry logs for apim event hub connection --- adapter/internal/messaging/connection.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adapter/internal/messaging/connection.go b/adapter/internal/messaging/connection.go index 5f8d2e099c..66b2106af0 100644 --- a/adapter/internal/messaging/connection.go +++ b/adapter/internal/messaging/connection.go @@ -72,7 +72,7 @@ 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 + "/") @@ -85,6 +85,8 @@ func connectionRetry(key string) (*Consumer, *amqp.Connection, error) { } return nil, rabbitConn, nil } + 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 { From 42daa16f747b031899881fc2726e068608976a50 Mon Sep 17 00:00:00 2001 From: hiranya Date: Thu, 8 Apr 2021 14:42:20 +0530 Subject: [PATCH 2/2] adding topic retry message --- adapter/internal/messaging/connection.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/adapter/internal/messaging/connection.go b/adapter/internal/messaging/connection.go index 66b2106af0..1d2fa2400f 100644 --- a/adapter/internal/messaging/connection.go +++ b/adapter/internal/messaging/connection.go @@ -75,6 +75,7 @@ func connectionRetry(key string) (*Consumer, *amqp.Connection, error) { 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 { @@ -85,8 +86,13 @@ func connectionRetry(key string) (*Consumer, *amqp.Connection, error) { } return nil, rabbitConn, nil } - logger.LoggerMsg.Infof("Retry attempt %d for the %s has failed. Retrying after %d seconds", - i, amqpURIArray[j].url, amqpURIArray[j].connectionDelay) + + 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 {