mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
AMQP: improve error handling of UUID extraction from message content #31
This commit is contained in:
parent
abb35ccfd9
commit
33d50a148d
1 changed files with 21 additions and 16 deletions
|
@ -122,7 +122,11 @@ func ConnectAMQP(uri string) error {
|
||||||
|
|
||||||
var sToBeUpdated database.Simulator
|
var sToBeUpdated database.Simulator
|
||||||
db := database.GetDB()
|
db := database.GetDB()
|
||||||
err = db.Where("UUID = ?", gjson.Get(content, "properties.uuid")).Find(sToBeUpdated).Error
|
simulatorUUID := gjson.Get(content, "properties.uuid").String()
|
||||||
|
if simulatorUUID == "" {
|
||||||
|
log.Println("AMQP: Could not extract UUID of simulator from content of received message, SIMULATOR NOT UPDATED")
|
||||||
|
} else {
|
||||||
|
err = db.Where("UUID = ?", simulatorUUID).Find(sToBeUpdated).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("AMQP: Unable to find simulator with UUID: ", gjson.Get(content, "properties.uuid"), " DB error message: ", err)
|
log.Println("AMQP: Unable to find simulator with UUID: ", gjson.Get(content, "properties.uuid"), " DB error message: ", err)
|
||||||
}
|
}
|
||||||
|
@ -141,6 +145,7 @@ func ConnectAMQP(uri string) error {
|
||||||
|
|
||||||
log.Println("AMQP: Updated simulator with UUID ", gjson.Get(content, "properties.uuid"))
|
log.Println("AMQP: Updated simulator with UUID ", gjson.Get(content, "properties.uuid"))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Add table
Reference in a new issue