Skip to content

Commit 6f7cece

Browse files
committed
Fixes for #222
1 parent 76d2dec commit 6f7cece

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
Newest updates are at the top of this file.
33

4+
## May 08 2025 - v5.6.2.1
5+
- mqmetric - Fixes for #222 and ibm-messaging/mq-metric-samples#395
6+
47
## Feb 28 2025 - v5.6.2
58
- Update for MQ 9.4.2
69
- ibmmq - Add function to map PCF attribute values to strings

mqmetric/discover.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,9 @@ func createSubscriptions() error {
10701070
// Don't have a qmgr-level subscription to this topic. Should
10711071
// only do this subscription once at startup
10721072
mqtd, err = subscribe(ty.ObjectTopic, &ci.si.replyQObj)
1073-
ty.subHobj[QMgrMapKey] = mqtd
1073+
if err == nil {
1074+
ty.subHobj[QMgrMapKey] = mqtd
1075+
}
10741076
}
10751077
}
10761078

mqmetric/mqif.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,14 @@ func initConnectionKey(key string, qMgrName string, replyQ string, replyQ2 strin
211211
ibmmq.MQIA_COMMAND_LEVEL,
212212
ibmmq.MQIA_PERFORMANCE_EVENT,
213213
ibmmq.MQIA_MAX_HANDLES,
214-
ibmmq.MQIA_PLATFORM,
215-
ibmmq.MQCA_VERSION}
214+
ibmmq.MQIA_PLATFORM}
216215

217216
v, err = ci.si.qMgrObject.Inq(selectors)
218217
if err == nil {
219218
ci.si.resolvedQMgrName = v[ibmmq.MQCA_Q_MGR_NAME].(string)
220219
ci.si.platform = v[ibmmq.MQIA_PLATFORM].(int32)
221220
ci.si.commandLevel = v[ibmmq.MQIA_COMMAND_LEVEL].(int32)
222221
ci.si.maxHandles = v[ibmmq.MQIA_MAX_HANDLES].(int32)
223-
ci.si.version = v[ibmmq.MQCA_VERSION].(string)
224222

225223
if ci.si.platform == ibmmq.MQPL_ZOS {
226224
ci.usePublications = false
@@ -243,6 +241,9 @@ func initConnectionKey(key string, qMgrName string, replyQ string, replyQ2 strin
243241
ci.usePublications = false
244242
}
245243
}
244+
} else {
245+
errorString = "Cannot inquire on queue manager object"
246+
mqreturn = err.(*ibmmq.MQReturn)
246247
}
247248
} else {
248249
errorString = "Cannot open queue manager object"
@@ -315,7 +316,10 @@ func initConnectionKey(key string, qMgrName string, replyQ string, replyQ2 strin
315316

316317
if err != nil {
317318
if mqreturn == nil {
318-
mqreturn = &ibmmq.MQReturn{MQCC: ibmmq.MQCC_WARNING, MQRC: ibmmq.MQRC_ENVIRONMENT_ERROR}
319+
mqreturn = &ibmmq.MQReturn{MQCC: ibmmq.MQCC_FAILED, MQRC: ibmmq.MQRC_ENVIRONMENT_ERROR}
320+
}
321+
if errorString == "" {
322+
errorString = err.Error()
319323
}
320324
traceExitErr("initConnectionKey", 1, mqreturn)
321325
return MQMetricError{Err: errorString, MQReturn: mqreturn}
@@ -498,7 +502,7 @@ func subscribeWithOptions(topic string, pubQObj *ibmmq.MQObject, managed bool, d
498502

499503
e2 := fmt.Errorf("Error subscribing to topic '%s': %v %s", topic, err, extraInfo)
500504
traceExitErr("subscribeWithOptions", 1, e2)
501-
return mqtd, e2
505+
return nil, e2
502506
}
503507

504508
mqtd.hObj = hObj

0 commit comments

Comments
 (0)