Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
VILLASframework
VILLASweb-backend-go
Commits
03341dbe
Commit
03341dbe
authored
Oct 26, 2020
by
Sonja Happ
Browse files
check if state field exists before processing a message
parent
cf8775b3
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
routes/infrastructure-component/amqpclient.go
View file @
03341dbe
...
@@ -261,13 +261,14 @@ func processMessage(message amqp.Delivery) error {
...
@@ -261,13 +261,14 @@ func processMessage(message amqp.Delivery) error {
return
fmt
.
Errorf
(
"AMQP: Could not unmarshal message to JSON: %v err: %v"
,
string
(
message
.
Body
),
err
)
return
fmt
.
Errorf
(
"AMQP: Could not unmarshal message to JSON: %v err: %v"
,
string
(
message
.
Body
),
err
)
}
}
if
payload
.
State
!=
nil
{
// if a message contains a "state" field, it is an update for an IC
ICUUID
:=
payload
.
Properties
.
UUID
ICUUID
:=
payload
.
Properties
.
UUID
_
,
err
=
uuid
.
Parse
(
ICUUID
)
_
,
err
=
uuid
.
Parse
(
ICUUID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"AMQP: UUID not valid: %v, message ignored: %v
\n
"
,
ICUUID
,
string
(
message
.
Body
))
return
fmt
.
Errorf
(
"AMQP: UUID not valid: %v, message ignored: %v
\n
"
,
ICUUID
,
string
(
message
.
Body
))
}
}
var
sToBeUpdated
InfrastructureComponent
var
sToBeUpdated
InfrastructureComponent
err
=
sToBeUpdated
.
ByUUID
(
ICUUID
)
err
=
sToBeUpdated
.
ByUUID
(
ICUUID
)
...
@@ -281,6 +282,6 @@ func processMessage(message amqp.Delivery) error {
...
@@ -281,6 +282,6 @@ func processMessage(message amqp.Delivery) error {
// update record based on payload
// update record based on payload
err
=
sToBeUpdated
.
updateICviaAMQP
(
payload
)
err
=
sToBeUpdated
.
updateICviaAMQP
(
payload
)
}
}
}
return
err
return
err
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment