@@ -28,7 +28,6 @@ import (
28
28
"fmt"
29
29
30
30
"github.com/ibm-messaging/mq-golang/ibmmq"
31
- "strings"
32
31
)
33
32
34
33
var (
38
37
statusReplyQObj ibmmq.MQObject
39
38
getBuffer = make ([]byte , 32768 )
40
39
platform int32
40
+ commandLevel int32
41
41
resolvedQMgrName string
42
42
43
43
qmgrConnected = false
@@ -82,25 +82,33 @@ func InitConnection(qMgrName string, replyQ string, cc *ConnectionConfig) error
82
82
}
83
83
84
84
// Discover important information about the qmgr - its real name
85
- // and the platform type
85
+ // and the platform type. Also check if it is at least V9 (on Distributed platforms)
86
+ // so that monitoring will work.
86
87
if err == nil {
88
+ var qMgrObject ibmmq.MQObject
89
+ var v map [int32 ]interface {}
90
+
87
91
mqod := ibmmq .NewMQOD ()
88
92
openOptions := ibmmq .MQOO_INQUIRE + ibmmq .MQOO_FAIL_IF_QUIESCING
89
93
90
94
mqod .ObjectType = ibmmq .MQOT_Q_MGR
91
95
mqod .ObjectName = ""
92
96
93
- qMgrObject , err : = qMgr .Open (mqod , openOptions )
97
+ qMgrObject , err = qMgr .Open (mqod , openOptions )
94
98
95
99
if err == nil {
96
100
selectors := []int32 {ibmmq .MQCA_Q_MGR_NAME ,
101
+ ibmmq .MQIA_COMMAND_LEVEL ,
97
102
ibmmq .MQIA_PLATFORM }
98
103
99
- intAttrs , charAttrs , err := qMgrObject .Inq (selectors , 1 , 48 )
100
-
104
+ v , err = qMgrObject .InqMap (selectors )
101
105
if err == nil {
102
- resolvedQMgrName = strings .TrimSpace (string (charAttrs [0 :48 ]))
103
- platform = intAttrs [0 ]
106
+ resolvedQMgrName = v [ibmmq .MQCA_Q_MGR_NAME ].(string )
107
+ platform = v [ibmmq .MQIA_PLATFORM ].(int32 )
108
+ commandLevel = v [ibmmq .MQIA_COMMAND_LEVEL ].(int32 )
109
+ if commandLevel < 900 && platform != ibmmq .MQPL_ZOS {
110
+ err = fmt .Errorf ("Queue manager must be at least V9.0 for monitoring." )
111
+ }
104
112
}
105
113
// Don't need the qMgrObject any more
106
114
qMgrObject .Close (0 )
@@ -246,3 +254,11 @@ can be turned into a string if necessary via ibmmq.MQItoString("PL"...)
246
254
func GetPlatform () int32 {
247
255
return platform
248
256
}
257
+
258
+ /*
259
+ Return the current platform - the MQPL_* definition value. It
260
+ can be turned into a string if necessary via ibmmq.MQItoString("PL"...)
261
+ */
262
+ func GetCommandLevel () int32 {
263
+ return commandLevel
264
+ }
0 commit comments