diff --git a/controller/eventService/Service.go b/controller/eventService/Service.go index 3ab30a42831b3a61b6a052f5166dbc7de2810043..b511c2002ea0971e901326bbfaec34082e07edaf 100644 --- a/controller/eventService/Service.go +++ b/controller/eventService/Service.go @@ -13,6 +13,7 @@ import ( amqp "github.com/rabbitmq/amqp091-go" "github.com/sethvargo/go-retry" + "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus" ) @@ -80,6 +81,7 @@ func NewEventService() (interfaces.Service, error) { } func connect(addr string) (*amqp.Connection, error) { + var err error retries := 60 for i := 0; i < retries; i++ { @@ -87,10 +89,11 @@ func connect(addr string) (*amqp.Connection, error) { if err == nil { return conn, nil } + logrus.Info("could not connect to RabbitMQ. Retrying in 2 seconds.") time.Sleep(2 * time.Second) } - return nil, &customerrs.AMQPInitFailError{Action: "failed to connect to RabbitMQ", Err: err} + return nil, &customerrs.AMQPInitFailError{Action: "finally failed to connect to RabbitMQ", Err: err} } // Reconnect attempts to setup a new connection to the RabbitMQ server after an disconnect.