Skip to content

Commit 630df01

Browse files
committed
Update for MQ 9.3.1
1 parent b8f10b5 commit 630df01

23 files changed

+910
-201
lines changed

CHANGELOG.md

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

4+
## Oct 17 2022 - v5.3.2
5+
- Update for MQ 9.3.1
6+
- mqmetric - New metric channel_cur_inst. All instances of a given channel name have this aggregated value.
7+
Done this way because the other labels for a channel object (eg jobname) make them unique so harder
8+
to see how many exist with the same basic name
9+
- mqmetric - Add metrics for AMQP channels
10+
- mqmetric - Add cluster name as tag for queues (#191)
11+
- Rewrite README to better match recent compiler versions and module management
12+
- Update expected Go compiler version
13+
414
## Jul 23 2022 - v5.3.1
515
- Fix #189 compile problem
616

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ARG BASE_IMAGE=ubuntu:18.04
1616
FROM $BASE_IMAGE
1717

1818
ARG GOPATH_ARG="/go"
19-
ARG GOVERSION=1.13.15
19+
ARG GOVERSION=1.17
2020

2121
ENV GOVERSION=${GOVERSION} \
2222
GOPATH=$GOPATH_ARG \
@@ -58,7 +58,7 @@ RUN mkdir -p $GOPATH/src $GOPATH/bin $GOPATH/pkg \
5858
# Location of the downloadable MQ client package \
5959
ENV RDURL="https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist" \
6060
RDTAR="IBM-MQC-Redist-LinuxX64.tar.gz" \
61-
VRMF=9.3.0.0
61+
VRMF=9.3.1.0
6262

6363
# Install the MQ client from the Redistributable package. This also contains the
6464
# header files we need to compile against. Setup the subset of the package

README.md

Lines changed: 64 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
This repository demonstrates how you can call IBM MQ from applications written in the Go language.
44

5-
This repository previously contained programs that exported MQ statistics to
6-
some monitoring packages. These have now been moved to a
7-
[GitHub repository called mq-metric-samples](https://github.com/ibm-messaging/mq-metric-samples).
5+
The repository originally also contained programs that exported MQ statistics to
6+
monitoring systems. These programs have been moved to a GitHub repository called [mq-metric-samples](https://github.com/ibm-messaging/mq-metric-samples).
87

9-
A minimum level of MQ V8 is required to build these packages. However, note that
10-
the monitoring data published by the queue manager and exploited in the mqmetric package
11-
is not available before MQ V9. A limited set of metrics can be monitored for MQ V8 instances by setting `ibmmq.usePublications=false`.
8+
A minimum level of MQ V8 is required to build these packages, although it should be possible to connect as a client to even older versions of queue manager.
129

1310
## Health Warning
1411

@@ -24,30 +21,31 @@ See the [DEPRECATIONS](DEPRECATIONS.md) file for any planned changes to the API.
2421

2522
## MQI Description
2623

27-
The ibmmq directory contains a Go package, exposing an MQI-like interface.
24+
The `ibmmq` directory contains a Go package, exposing an MQI-like interface.
2825

2926
The intention is to give an API that is more natural for Go programmers than the
3027
common procedural MQI. For example, fixed length string arrays from the C API such
3128
as MQCHAR48 are represented by the native Go string type. Conversion between these
32-
types is handled within the ibmmq package itself, removing the need for Go programmers
29+
types is handled within the `ibmmq` package itself, removing the need for Go programmers
3330
to know about it.
3431

3532
Sample programs are provided to demonstrate various features of using the MQI. See the
36-
README in the `samples` directory for more information about those programs.
33+
README in the `samples` directory for more information about those programs. Detailed information about the MQI and application design can be found in the MQ product
34+
documentation. Although that doesn't mention Go as a language, the principles for all
35+
applications apply.
3736

38-
The mqmetric directory contains functions to help monitoring programs access MQ status and
39-
statistics. This package is not needed for general application programs.
37+
The `mqmetric` directory contains functions to help monitoring programs access MQ status and statistics. This package is not needed for general application programs.
4038

4139
## Using the package
4240

4341
To use code in this repository, you will need to be able to build Go applications, and
44-
have a copy of MQ installed to build against. It uses cgo to access the MQI C
42+
have a copy of MQ installed to build against. It uses `cgo` to access the MQI C
4543
structures and definitions. It assumes that MQ has been installed in the default
4644
location (on a Linux platform this would be `/opt/mqm`) but this can be changed
4745
with environment variables if necessary.
4846

49-
Windows compatibility is also included. This has been tested with Go 1.10 compiler,
50-
which now permits standard Windows paths (eg including spaces) so the CGO directives
47+
Windows compatibility is also included. Current versions of the Go compiler
48+
permit standard Windows paths (eg including spaces) so the CGO directives
5149
can point at the normal MQ install path.
5250

5351
## Getting started
@@ -56,129 +54,105 @@ If you are unfamiliar with Go, the following steps can help create a working env
5654
with source code in a suitable tree. Initial setup tends to be platform-specific,
5755
but subsequent steps are independent of the platform.
5856

59-
### Linux
60-
61-
* Install the Go runtime and compiler. On Linux, the packaging may vary but a typical
62-
directory for the code is `/usr/lib/golang`. If you see an error similar to "ld: NULL not defined"
63-
when building a program then it is likely you need to upgrade your compiler.
64-
65-
66-
* Create a working directory. For example, ```mkdir $HOME/gowork```
67-
68-
* Set environment variables. Based on the previous lines,
57+
### MQ Client SDK
58+
The MQ Client SDK for C programs is required in order to compile and run Go programs. You may have this from an MQ Client installation image (eg rpm, dep for Linux; msi for
59+
Windows).
6960

70-
```
71-
export GOROOT=/usr/lib/golang
72-
export GOPATH=$HOME/gowork
73-
```
61+
For Linux x64 and Windows systems, you may also choose to use the
62+
MQ Redistributable Client package which is a simple zip/tar file that does not need
63+
any privileges to install:
7464

75-
* On Linux, some versions of the compiler have required that you set environment variables to permit some compile/link flags. Recent versions of Go seem to effectively include this fix in the compiler so that the export is no longer necessary.
65+
* Download [IBM MQ redistributable client](https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist)
66+
* Unpack archive to fixed directory. E.g. `c:\IBM-MQC-Redist-Win64` or `/opt/mqm`.
7667

77-
```
78-
export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
79-
```
68+
### Linux
8069

81-
* Install the git client
70+
* Install the Go runtime and compiler. On Linux, the packaging may vary but a typical
71+
directory for the code is `/usr/lib/golang`.
72+
* Create a working directory. For example, ```mkdir $HOME/gowork```
73+
* Install the git client and the gcc C compiler
8274

8375
### Windows
8476

8577
* Install the Go runtime and compiler. On Windows, the common directory is `c:\Go`
86-
* Ensure you have a gcc-based compiler. The variant that now seems to be recommended for cgo is
78+
* Ensure you have a gcc-based compiler. The variant that seems to be recommended for cgo is
8779
the [tdm-gcc-64](https://jmeubank.github.io/tdm-gcc/download/) 64-bit compiler suite.
8880
The default `gcc` compiler from Cygwin does not work because it tries to build a
8981
Cygwin-enabled executable but the MQ libraries do not work in that model;
9082
the `mingw` versions build Windows-native programs.
9183
* Create a working directory. For example, `mkdir c:\Gowork`
92-
* Set environment variables. Based on the previous lines,
93-
84+
* Set an environment variable for the compiler
9485
```
95-
set GOROOT=c:\Go
96-
set GOPATH=c:\Gowork
9786
set CC=x86_64-w64-mingw32-gcc.exe
9887
```
9988

100-
* The `CGO_LDFLAGS_ALLOW` variable is not needed on Windows
101-
* Install the git client
102-
103-
#### (Optional) Prepare without installed MQ Server or MQ Client
104-
105-
* Download [IBM MQ redistributable client for Windows](https://www.ibm.com/support/fixcentral/swg/selectFixes?parent=ibm%7EWebSphere&product=ibm/WebSphere/WebSphere+MQ&release=All&platform=All&function=fixId&fixids=*IBM-MQC-Redist-*&includeSupersedes=0)
106-
* Unpack archive to fixed directory. E.g. `c:\IBM-MQC-Redist-Win64`
107-
* Set environment variables (overrides vars in following section **Common**):
108-
```
109-
set CGO_CFLAGS=-Ic:\IBM-MQC-Redist-Win64\tools\c\include -D_WIN64
110-
set CGO_LDFLAGS=-L c:\IBM-MQC-Redist-Win64\bin64 -lmqm
111-
```
11289
### Common
11390

114-
* Make sure your PATH includes routes to the Go compiler (`$GOROOT/bin`), the Git client, and the C compiler.
115-
* Change directory to the workspace you created earlier. (`cd $GOPATH`)
91+
* Make sure your PATH includes routes to the Go compiler, the Git client, and the C compiler.
92+
* Change to the directory you created earlier.
11693
* Use git to get a copy of the MQ components into a new directory in the workspace.
11794

118-
`git clone https://github.com/ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang`
95+
`git clone git@github.com:ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang`
11996

12097
* If you have not installed MQ libraries into the default location, then set environment variables
121-
for the C compiler to recognise those directories. You may get messages from the compiler
98+
for the C compiler to recognise those directories. You may then get messages from the compiler
12299
saying that the default MQ directories cannot be found, but those warnings can be ignored.
123100
The exact values for these environment variables will vary by platform, but follow the
124101
corresponding CFLAGS/LDFLAGS values in `mqi.go`
125102

126-
For example,
103+
For example, on Linux:
127104

128105
```
129106
export MQ_INSTALLATION_PATH=/my/mq/dir # This will also be set from the setmqenv command
130-
131107
export CGO_CFLAGS="-I$MQ_INSTALLATION_PATH/inc"
132-
133108
export CGO_LDFLAGS="-L$MQ_INSTALLATION_PATH/lib64 -Wl,-rpath,$MQ_INSTALLATION_PATH/lib64"
134109
```
135110

136-
* Compile the `ibmmq` component:
137-
*
138-
`go install ./src/github.com/ibm-messaging/mq-golang/ibmmq`
111+
Or on Windows:
139112

140-
* If you plan to use monitoring functions, then compile the `mqmetric` component:
141-
142-
`go install ./src/github.com/ibm-messaging/mq-golang/mqmetric`
113+
```
114+
set CGO_CFLAGS=-Ic:\IBM-MQC-Redist-Win64\tools\c\include -D_WIN64
115+
set CGO_LDFLAGS=-L c:\IBM-MQC-Redist-Win64\bin64 -lmqm
116+
```
143117

144-
* Sample programs can be compiled in this way
118+
* Sample programs can be compiled directly:
145119

146-
`go build -o bin/mqitest ./src/github.com/ibm-messaging/mq-golang/samples/mqitest/*.go`
120+
```
121+
cd src/github.com/ibm-messaging/mq-golang/samples
122+
go build -o /tmp/mqitest mqitest/*.go
123+
```
147124

148-
At this point, you should have a compiled copy of the program in `$GOPATH/bin`. See the
125+
At this point, you should have a compiled copy of the program in `/tmp`. See the
149126
`samples` directory for more sample programs.
150127

151-
### Build errors
152-
If you get errors such as `cannot find package v5/ibmmq` then one solution is to go to
153-
the repository directory itself: `cd ./src/github.com/ibm-messaging/mq-golang`. And
154-
then compile directly from that directory: `go install ./ibmmq`, `go install ./samples/amqsput.go`.
155-
156-
An alternative is to set GOPATH to the directory you have tried to compile
157-
from: `export GOPATH=$HOME/gowork`.
158128

159129
## Building in a container
160130
The `buildSamples.sh` script in this directory can also be used to create a container which will
161-
compile the samples and copy them to a local directory. If you use this approach, you do not need
162-
to install a local copy of the compiler and associated toold, though you will still need a copy of
163-
the MQ runtime libraries for wherever you execute the programs.
131+
install the MQ Client SDK, compile the samples and copy them to a local directory. If you use this approach, you do not need
132+
to install a local copy of the compiler and associated tools, though you will still need a copy of
133+
the MQ C client runtime libraries for wherever you execute the programs.
164134

165135
## Go Modules
166-
The packages in this repository are now set up to be used as Go modules. See the `go.mod` file in
167-
the root of the repository. This required a major version bump in the release stream.
136+
The packages in this repository are set up to be used as Go modules. See the `go.mod` file in
137+
the root of the repository.
168138

169139
Support for modules started to be introduced around Go 1.11 and has been firmed up in various
170-
modification level updates in each of the compiler levels since then. The module changes for this
171-
package were developed and tested with Go 1.13.6.
140+
modification level updates in each of the compiler levels since then. It is now recommended to
141+
use at least version 1.17 of the compiler.
142+
143+
Use of modules means that packages do not need to be independently compiled or
144+
installed. Environment variables such as `GOROOT` and `GOPATH` that were previously required are
145+
now redundant in module mode.
172146

173147
To use the MQ module in your application, your `go.mod` file contains
174148

175149
```
176150
require (
177-
github.com/ibm-messaging/mq-golang/v5 v5.0.0
151+
github.com/ibm-messaging/mq-golang/v5 v5.x.y
178152
)
179153
```
180154

181-
and your application code will include
155+
and your application code includes
182156

183157
```
184158
import ibmmq "github.com/ibm-messaging/mq-golang/v5/ibmmq"
@@ -192,6 +166,7 @@ of these packages. For example, you can continue to use `dep` with `Gopkg.toml`
192166
name = "github.com/ibm-messaging/mq-golang"
193167
version = "4.1.4"
194168
```
169+
Those older versions are not maintained, so it is strongly recommended you do move to using modules.
195170

196171
## Related Projects
197172

@@ -209,15 +184,15 @@ let me know, via an issue, if you have another project that might be suitable fo
209184
## Limitations
210185

211186
### Package 'ibmmq'
212-
All regular MQI verbs are now available through the `ibmmq` package.
213-
214-
The only unimplemented area of MQI function is the use of Distribution Lists: they were
187+
* All regular MQI verbs are available through the `ibmmq` package.
188+
* The only unimplemented area of MQI function is the use of Distribution Lists: they were
215189
rarely used, and the Publish/Subscribe operations provide similar capability.
190+
* Go is not supported for writing MQ Exits, so structures and methods for those features
191+
are not included.
216192

217193
### Package 'mqmetric'
218-
* There is currently a queue manager limitation which does not permit resource publications to
219-
be made about queues whose name includes '/'. Attempting to monitor such a queue will result in a warning
220-
logged by the mqmetric package.
194+
* The monitoring data published by the queue manager and exploited in the mqmetric package is not available before MQ V9. A limited set of metrics can be monitored for MQ V8 instances by setting the `ConnectionConfig.UsePublications` configuration option to `false`.
195+
* There is currently a queue manager limitation which does not permit resource publications to be made about queues whose name includes '/'. Attempting to monitor such a queue will result in a warning logged by the mqmetric package.
221196

222197
## History
223198

@@ -238,4 +213,4 @@ in the CLA.
238213

239214
## Copyright
240215

241-
© Copyright IBM Corporation 2016, 2021
216+
© Copyright IBM Corporation 2016, 2022

buildInDocker.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,29 @@ cd $GOPATH/src
3030
echo "Using compiler:"
3131
go version
3232

33+
# No longer need to explicitly build packages as
34+
# modules manage the download/installation. And the latest
35+
# compilers have the original version of commands as
36+
# errors. So we comment out that phase.
3337
for pkg in $ORG/$REPO/ibmmq $ORG/$REPO/mqmetric
3438
do
3539
lib=`basename $pkg`
36-
echo "Building package: $lib"
37-
go install $pkg
40+
: echo "Building package: $lib"
41+
: go install $pkg
3842
done
3943

40-
# And do the sample program builds into the bin directory
44+
# Do the sample program builds into the bin directory
4145
cd $GOPATH
4246
srcdir=src/$ORG/$REPO/samples
4347

44-
for samp in $srcdir/*.go
48+
cd $srcdir
49+
for samp in *.go
4550
do
4651
exe=`basename $samp .go`
4752
echo "Building program: $exe"
48-
go build -o bin/$exe $samp
53+
go build -o $GOPATH/bin/$exe $samp
4954
done
5055

5156
echo "Building program: mqitest"
52-
go build -o bin/mqitest $srcdir/mqitest/mqitest.go
57+
go build -o $GOPATH/bin/mqitest mqitest/mqitest.go
5358

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/ibm-messaging/mq-golang/v5
22

3-
go 1.13
3+
go 1.16

0 commit comments

Comments
 (0)