@@ -28,7 +28,6 @@ import (
2828 "fmt"
2929
3030 "github.com/ibm-messaging/mq-golang/ibmmq"
31- "strings"
3231)
3332
3433var (
3837 statusReplyQObj ibmmq.MQObject
3938 getBuffer = make ([]byte , 32768 )
4039 platform int32
40+ commandLevel int32
4141 resolvedQMgrName string
4242
4343 qmgrConnected = false
@@ -82,25 +82,33 @@ func InitConnection(qMgrName string, replyQ string, cc *ConnectionConfig) error
8282 }
8383
8484 // 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.
8687 if err == nil {
88+ var qMgrObject ibmmq.MQObject
89+ var v map [int32 ]interface {}
90+
8791 mqod := ibmmq .NewMQOD ()
8892 openOptions := ibmmq .MQOO_INQUIRE + ibmmq .MQOO_FAIL_IF_QUIESCING
8993
9094 mqod .ObjectType = ibmmq .MQOT_Q_MGR
9195 mqod .ObjectName = ""
9296
93- qMgrObject , err : = qMgr .Open (mqod , openOptions )
97+ qMgrObject , err = qMgr .Open (mqod , openOptions )
9498
9599 if err == nil {
96100 selectors := []int32 {ibmmq .MQCA_Q_MGR_NAME ,
101+ ibmmq .MQIA_COMMAND_LEVEL ,
97102 ibmmq .MQIA_PLATFORM }
98103
99- intAttrs , charAttrs , err := qMgrObject .Inq (selectors , 1 , 48 )
100-
104+ v , err = qMgrObject .InqMap (selectors )
101105 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+ }
104112 }
105113 // Don't need the qMgrObject any more
106114 qMgrObject .Close (0 )
@@ -246,3 +254,11 @@ can be turned into a string if necessary via ibmmq.MQItoString("PL"...)
246254func GetPlatform () int32 {
247255 return platform
248256}
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