Skip to content

Commit

Permalink
Merge pull request #47 from parrobe/errorhandle
Browse files Browse the repository at this point in the history
check rc incase it is not no_more_msg
  • Loading branch information
parrobe authored May 31, 2018
2 parents 3541d35 + d4a05b0 commit f15a287
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
10 changes: 9 additions & 1 deletion mqmetric/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ cases where multiple pieces of data have to be collated for the same
gauge. Conversely, there may be times when this is called but there
are no metrics to update.
*/
func ProcessPublications() {
func ProcessPublications() error {
var err error
var data []byte

Expand Down Expand Up @@ -568,8 +568,16 @@ func ProcessPublications() {
elem.Values[objectName] = value
}
}
} else {
// err != nil
mqreturn := err.(*ibmmq.MQReturn)

if mqreturn.MQCC == ibmmq.MQCC_FAILED && mqreturn.MQRC != ibmmq.MQRC_NO_MSG_AVAILABLE {
return mqreturn
}
}
}
return nil
}

/*
Expand Down
13 changes: 0 additions & 13 deletions mqmetric/mqif.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ func getMessage(wait bool) ([]byte, error) {
func getMessageWithHObj(wait bool, hObj ibmmq.MQObject) ([]byte, error) {
var err error
var datalen int
var mqreturn *ibmmq.MQReturn

getmqmd := ibmmq.NewMQMD()
gmo := ibmmq.NewMQGMO()
Expand All @@ -196,18 +195,6 @@ func getMessageWithHObj(wait bool, hObj ibmmq.MQObject) ([]byte, error) {
}

datalen, err = replyQObj.Get(getmqmd, gmo, getBuffer)
if err != nil {
mqreturn = err.(*ibmmq.MQReturn)

if mqreturn.MQRC == ibmmq.MQRC_Q_MGR_NOT_AVAILABLE ||
mqreturn.MQRC == ibmmq.MQRC_Q_MGR_NAME_ERROR ||
mqreturn.MQRC == ibmmq.MQRC_Q_MGR_QUIESCING {
return nil, fmt.Errorf("Queue Manager error: %v", err)
}
if mqreturn.MQCC == ibmmq.MQCC_FAILED && mqreturn.MQRC != ibmmq.MQRC_NO_MSG_AVAILABLE {
return nil, fmt.Errorf("Get message error: %v", err)
}
}

return getBuffer[0:datalen], err
}
Expand Down

0 comments on commit f15a287

Please sign in to comment.