Skip to content

Commit 19b946c

Browse files
committed
Issue warnings if trying to get stats for qnames containing '.'
1 parent f459b90 commit 19b946c

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Changelog
22
Newest updates are at the top of this file.
33

4-
## August 2 2019 - v4.1.0
4+
## Augest 20 2019 - v4.1.0
5+
* Update Docker build scripts for newer Go compiler level
6+
* mqmetric - Issue warning if trying to monitor queues with names containing '/'
7+
8+
## August 2 2019 - unpublished
59
* ibmmq - Add new verb GetSlice to mirror Get() but which returns ready-sized buffer (#110)
610
* See updated sample amqsget.go
711
* Some comment tidying up. Make CMQC constants constant.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,14 @@ let me know, via an issue, if you have another project that might be suitable fo
155155

156156
## Limitations
157157

158+
### Package 'ibmmq'
158159
All regular MQI verbs are now available through the `ibmmq` package.
159160

161+
### Package 'mqmetric'
162+
* There is currently a queue manager limitation which does not permit resource publications to
163+
be made about queues whose name includes '/'. Attempting to monitor such a queue will result in a warning
164+
logged by the mqmetric package.
165+
160166
## History
161167

162168
See [CHANGELOG](CHANGELOG.md) in this directory.

mqmetric/discover.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ const defaultMaxQDepth = 5000
9797
// Metrics is the global variable for the tree of data
9898
var Metrics AllMetrics
9999

100+
// Only issue the warning about a '/' in queue name once.
101+
var globalSlashWarning = false;
102+
var localSlashWarning = false;
103+
100104
var qInfoMap map[string]*QInfo
101105
var locale string
102106
var discoveryDone = false
@@ -550,12 +554,28 @@ func discoverQueues(monitoredQueuePatterns string) error {
550554
qList, err = inquireObjects(monitoredQueuePatterns, ibmmq.MQOT_Q)
551555
}
552556

557+
localSlashWarning = false
553558
if len(qList) > 0 {
554559
//fmt.Printf("Monitoring Queues: %v\n", qList)
555560
for i := 0; i < len(qList); i++ {
556561
var qInfoElem *QInfo
557562
var ok bool
558563
qName := strings.TrimSpace(qList[i])
564+
565+
// If the qName contains a '/' - eg "DEV/QUEUE/1" then the queue manager will
566+
// not (right now) process resource publications correctly. Hopefully that will get
567+
// fixed at some point, but we will issue a warning here. The same problem happens with
568+
// amqsrua; there's no workround possible outside of the qmgr code.
569+
//
570+
// Because of the possible complexities of pattern matching, we don't
571+
// actually fail the discovery process, but instead issue a warning and continue with
572+
// other queues.
573+
if strings.Contains(qName,"/") && globalSlashWarning == false {
574+
localSlashWarning = true // First time through, issue the warning for all queues
575+
logError("Warning: Cannot subscribe to queue containing '/': %s",qName)
576+
continue
577+
}
578+
559579
if qInfoElem, ok = qInfoMap[qName]; !ok {
560580
qInfoElem = new(QInfo)
561581
}
@@ -576,11 +596,16 @@ func discoverQueues(monitoredQueuePatterns string) error {
576596
}
577597
}
578598

599+
if localSlashWarning {
600+
globalSlashWarning = true
601+
}
602+
579603
if err != nil {
580604
//fmt.Printf("Queue Discovery Error: %v\n", err)
581605
}
582606
return nil
583607
}
608+
584609
return err
585610
}
586611

@@ -722,7 +747,10 @@ func inquireObjects(objectPatternsList string, objectType int32) ([]string, erro
722747
missingPatterns = missingPatterns + " " + pattern
723748
}
724749
for i := 0; i < len(elem.String); i++ {
725-
objectList = append(objectList, strings.TrimSpace(elem.String[i]))
750+
s := strings.TrimSpace(elem.String[i])
751+
752+
objectList = append(objectList, s)
753+
726754
}
727755
}
728756
}

mqmetric/log.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ package mqmetric
1919
Mark Taylor - Initial Contribution
2020
*/
2121

22+
import (
23+
"fmt"
24+
)
25+
2226
type Logger struct {
2327
Debug func(string, ...interface{})
2428
Info func(string, ...interface{})
@@ -41,8 +45,11 @@ func logInfo(format string, v ...interface{}) {
4145
logger.Info(format, v...)
4246
}
4347
}
48+
// Errors should be reported always
4449
func logError(format string, v ...interface{}) {
45-
if logger != nil && logger.Info != nil {
50+
if logger != nil && logger.Error != nil {
4651
logger.Error(format, v...)
52+
} else {
53+
fmt.Printf(format,v...)
4754
}
4855
}

0 commit comments

Comments
 (0)