Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 79 additions & 71 deletions CHANGES.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,95 @@
# Changelog

08 Jul 2016
* Initial release
## May 2018

18 Jul 2016
* Changed structures so that most applications will not need to use cgo to imbed the MQ C headers
* Go programs will now use int32 where C programs use MQLONG
* Use of message handles, distribution lists require cgo for now
* Package ibmmq now includes the numeric #defines as a Go file, cmqc.go, for easier use
* Removed "src/" prefix from tree in github repo
* Removed need for buffer length parm on Put/Put1
* Updated comments
* Added MQINQ
* Added MQItoString function for some maps of values to constant names
* Corrected package imports
* Formatted go code with `go fmt`
* Rearranged this file
* Removed logging from golang package `mqmetric`
* Moved samples to a separate repository

25 Jul 2016
* Added functions to handle basic PCF creation and parsing
* Added a monitor command for exporting MQ V9 queue manager data to Prometheus. See
the [README](cmd/mq_prometheus/README.md) for more details

04 Aug 2016
* Added a monitor command for exporting MQ data to InfluxDB. See the [README]
(cmd/mq_influx/README.md) for more details
* Restructured the monitoring code to put common material in the mqmetric
package, called from the Influx and Prometheus monitors.

12 Aug 2016
* Added a OpenTSDB monitor. See the [README](cmd/mq_opentsdb/README.md) for
more details.
* Added a Collectd monitor. See the [README](cmd/mq_coll/README.md) for
more details.
* Added MQI MQCNO/MQCSP structures to support client connections and password authentication
with MQCONNX.
* Allow client-mode connections from the monitor programs
* Added Grafana dashboards for the different monitors to show how to query them
* Changed database password mechanism so that "exec" maintains the PID for MQ services
## March 2018 - v1.0.0

23 Aug 2016
* Added a collector for Amazon AWS CloudWatch monitoring. See the [README](cmd/mq_aws/README.md)
for more details.
* Added V9.0.5 constant definitions
* Changed #cgo directives for Windows now the compiler supports standard path names
* Added mechanism to set MQ userid and password for Prometheus monitor
* Released v1.0.0 of this repository for use with golang dependency management tools

17 Oct 2016
* Added some Windows support. An example batch file is included in the mq_influx directory;
changes would be needed to the MQSC script to call it. The other monitor programs can be
supported with similar modifications.
* Added a "getting started" section to this README.
## October 2017

07 Nov 2016
* Added a collector that prints metrics in a simple JSON format.
See the [README](cmd/mq_json/README.md) for more details.
* Fixed bug where freespace metrics were showing as non-integer bytes, not percentages
* Added V9.0.4 constant definitions - now generated from original MQ source code
* Added MQSC script to show how to redefine event queues for pub/sub
* Prometheus collector has new parameter to override the first component of the metric name
* Prometheus collector can now process channel-level statistics

## 18 May 2017

* Added the V9.0.3 constant definitions.
* Reinstated 64-bit structure "length" fields in cmqc.go after fixing a bug in the base product C source code generator.

## 25 Mar 2017

* Added the metaPrefix option to the Prometheus monitor. This allows selection of non-default resources such as the MQ Bridge for Salesforce included in MQ 9.0.2.

## 15 Feb 2017

* API BREAKING CHANGE: The MQI verbs have been changed to return a single error indicator instead of two separate values. See mqitest.go for examples of how MQRC/MQCC codes can now be tested and extracted. This change makes the MQI implementation a bit more natural for Go environments.

## 10 Jan 2017

* Added support for the MQCD and MQSCO structures to allow programmable client connectivity, without requiring a CCDT. See the clientconn sample program for an example of using the MQCD.
* Moved sample programs into subdirectory

## 14 Dec 2016

14 Dec 2016
* Minor updates to this README for formatting
* Removed xxx_CURRENT_LENGTH definitions from cmqc

10 Jan 2017
* Added support for the MQCD and MQSCO structures to allow programmable client
connectivity, without requiring a CCDT. See the clientconn sample program
for an example of using the MQCD.
* Moved sample programs into subdirectory
## 07 Nov 2016

15 Feb 2017
* API BREAKING CHANGE: The MQI verbs have been changed to return a single
error indicator instead of two separate values. See mqitest.go for
examples of how MQRC/MQCC codes can now be tested and extracted. This change
makes the MQI implementation a bit more natural for Go environments.
* Added a collector that prints metrics in a simple JSON format. See the [README](cmd/mq_json/README.md) for more details.
* Fixed bug where freespace metrics were showing as non-integer bytes, not percentages

25 Mar 2017
* Added the metaPrefix option to the Prometheus monitor. This allows selection of non-default resources such as the MQ Bridge for Salesforce included in MQ 9.0.2.
## 17 Oct 2016

18 May 2017
* Added the V9.0.3 constant definitions.
* Reinstated 64-bit structure "length" fields in
cmqc.go after fixing a bug in the base product C source code generator.
* Added some Windows support. An example batch file is included in the mq_influx directory; changes would be needed to the MQSC script to call it. The other monitor programs can be supported with similar modifications.
* Added a "getting started" section to this README.

October 2017
* Added V9.0.4 constant definitions - now generated from original MQ source code
* Added MQSC script to show how to redefine event queues for pub/sub
* Prometheus collector has new parameter to override the first component of the metric name
* Prometheus collector can now process channel-level statistics
## 23 Aug 2016

March 2018
* Added V9.0.5 constant definitions
* Changed #cgo directives for Windows now the compiler supports standard path names
* Added mechanism to set MQ userid and password for Prometheus monitor
* Added a collector for Amazon AWS CloudWatch monitoring. See the [README](cmd/mq_aws/README.md) for more details.

## 12 Aug 2016

* Added a OpenTSDB monitor. See the [README](cmd/mq_opentsdb/README.md) for more details.
* Added a Collectd monitor. See the [README](cmd/mq_coll/README.md) for more details.
* Added MQI MQCNO/MQCSP structures to support client connections and password authentication with MQCONNX.
* Allow client-mode connections from the monitor programs
* Added Grafana dashboards for the different monitors to show how to query them
* Changed database password mechanism so that "exec" maintains the PID for MQ services

## 04 Aug 2016

* Added a monitor command for exporting MQ data to InfluxDB. See the [README](cmd/mq_influx/README.md) for more details
* Restructured the monitoring code to put common material in the mqmetric package, called from the Influx and Prometheus monitors.

## 25 Jul 2016

* Added functions to handle basic PCF creation and parsing
* Added a monitor command for exporting MQ V9 queue manager data to Prometheus. See the [README](cmd/mq_prometheus/README.md) for more details

## 18 Jul 2016

* Changed structures so that most applications will not need to use cgo to imbed the MQ C headers
* Go programs will now use int32 where C programs use MQLONG
* Use of message handles, distribution lists require cgo for now
* Package ibmmq now includes the numeric #defines as a Go file, cmqc.go, for easier use
* Removed "src/" prefix from tree in github repo
* Removed need for buffer length parm on Put/Put1
* Updated comments
* Added MQINQ
* Added MQItoString function for some maps of values to constant names

## 08 Jul 2016

* Initial release
123 changes: 58 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,126 +1,115 @@
# mq-golang

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

> **NOTICE**: Please ensure that you use a dependency management tool such as [dep](https://github.com/golang/dep) or [Glide](http://glide.sh/), and add a specific version dependency. The current content has been marked as version 1.0.0, and a new version with breaking changes will be released soon. By using a dependency manager, you can continue to use the old version if you want to.

The repository also includes programs to export MQ statistics to some monitoring
packages including Prometheus, InfluxDB and OpenTSDB.
This repository previously contained sample programs that exported MQ statistics to some monitoring packages. These have now been moved to a new [GitHub repository called mq-metric-samples](https://github.com/ibm-messaging/mq-metric-samples).

A minimum level of MQ V9 is required to build this package.
The monitoring data published by the queue manager is not available before
that version; the interface also assumes availability of
MQI structures from that level of MQ.
A minimum level of MQ V9 is required to build these packages.
The monitoring data published by the queue manager is not available before that version; the interface also assumes availability of MQI structures from that level of MQ.

## Health Warning

This package is provided as-is with no guarantees of support or updates. There are also no guarantees of compatibility
with any future versions of the package; the API is subject to change based on any feedback.
This package is provided as-is with no guarantees of support or updates. There are also no guarantees of compatibility with any future versions of the package; the API is subject to change based on any feedback.

## MQI Description

The ibmmq directory contains a Go package, exposing an MQI-like interface.

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

A short program in the mqitest directory gives an example of using this interface, to put and get messages
and to subscribe to a topic.
A short program in the mqitest directory gives an example of using this interface, to put and get messages and to subscribe to a topic.

Feedback on the utility of this package, thoughts about whether it should be changed or extended are
welcomed.
Feedback on the utility of this package, thoughts about whether it should be changed or extended are welcomed.

## Using the package

To use code in this repository, you will need to be able to build Go applications, and
have a copy of MQ installed to build against. It uses cgo to access the MQI C structures and definitions. It assumes that MQ has been
installed in the default location on a Linux platform (/opt/mqm) but you can easily change the
cgo directives in the source files if necessary.
To use code in this repository, you will need to be able to build Go applications, and have a copy of MQ installed to build against. It uses cgo to access the MQI C structures and definitions. It assumes that MQ has been installed in the default location on a Linux platform (`/opt/mqm`) but you can easily change the cgo directives in the source files if necessary.

Some Windows capability is also included. This has been tested with Go 1.10
compiler, which now permits standard Windows paths (eg including spaces)
so the CGO directives can point at the normal MQ install path.
Some Windows capability is also included. This has been tested with Go 1.10 compiler, which now permits standard Windows paths (eg including spaces) so the CGO directives can point at the normal MQ install path.

## Getting started

If you are unfamiliar with Go, the following steps can help create a
working environment with source code in a suitable tree. Initial setup
tends to be platform-specific, but subsequent steps are independent of the
platform.
If you are unfamiliar with Go, the following steps can help create a working environment with source code in a suitable tree. Initial setup tends to be platform-specific, but subsequent steps are independent of the platform.

### Linux

* Install the Go runtime and compiler. On Linux, the packaging may vary
but a typical directory for the code is /usr/lib/golang.
* Create a working directory. For example, mkdir $HOME/gowork
* Install the Go runtime and compiler. On Linux, the packaging may vary but a typical directory for the code is `/usr/lib/golang`.

* Create a working directory. For example, ```mkdir $HOME/gowork```

* Set environment variables. Based on the previous lines,

export GOROOT=/usr/lib/golang
```export GOROOT=/usr/lib/golang```

```export GOPATH=$HOME/gowork```

export GOPATH=$HOME/gowork
* If using a version of Go from after 2017, you must set environment variables to permit some compile/link flags. This is due to a security fix in the compiler.

* If using a version of Go from after 2017, you must set environment variables
to permit some compile/link flags. This is due to a security fix in the compiler.
export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"
```export CGO_LDFLAGS_ALLOW="-Wl,-rpath.*"```

* Install the git client

### Windows

* Install the Go runtime and compiler. On Windows, the
common directory is c:\Go
* Ensure you have a gcc-based compiler, for example from the Cygwin
distribution. I use the mingw variation, to ensure compiled code can
be used on systems without Cygwin installed
* Create a working directory. For example, mkdir c:\Gowork
* Install the Go runtime and compiler. On Windows, the common directory is `c:\Go`
* Ensure you have a gcc-based compiler, for example from the Cygwin distribution. I use the mingw variation, to ensure compiled code can be used on systems without Cygwin installed
* Create a working directory. For example, ```mkdir c:\Gowork```
* Set environment variables. Based on the previous lines,

set GOROOT=c:\Go
```set GOROOT=c:\Go```

set GOPATH=c:\Gowork
```set GOPATH=c:\Gowork```

set CC=x86_64-w64-mingw32-gcc.exe
```set CC=x86_64-w64-mingw32-gcc.exe```

* The CGO_LDFLAGS_ALLOW variable is not needed on Windows
* The `CGO_LDFLAGS_ALLOW` variable is not needed on Windows
* Install the git client
* Make sure the MQ include files and libraries are in a path that does
not include spaces or other special characters, as discussed above.
* Make sure the MQ include files and libraries are in a path that does not include spaces or other special characters, as discussed above.

### Common

* Make sure your PATH includes routes to the Go compiler ($GOROOT/bin),
the Git client, and the C compiler.
* Change directory to the workspace you created earlier. (cd $GOPATH)
* Use git to get a copy of the MQ components into a new directory in the
workspace. Use "src" as the destination, to get the directory created
automatically; this path will then be searched by the Go compiler.
* Make sure your PATH includes routes to the Go compiler (`$GOROOT/bin`), the Git client, and the C compiler.
* Change directory to the workspace you created earlier. (`cd $GOPATH`)
* Use git to get a copy of the MQ components into a new directory in the workspace.

```git clone https://github.com/ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang```

* Use Go to download prerequisite components for any monitors you are interested in running. The logrus package is required for all of the monitors; but not all of the monitors require further downloads.

```go get -u github.com/Sirupsen/logrus```

git clone https://github.com/ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang
```go get -u github.com/prometheus/client_golang/prometheus```

* Use Go to download prerequisite components for any monitors you are interested
in running. The logrus package is required for all of the monitors; but not
all of the monitors require further downloads.
```go get -u github.com/influxdata/influxdb/client/v2```

go get -u github.com/Sirupsen/logrus
```go get -u github.com/aws/aws-sdk-go/service```

go get -u github.com/prometheus/client_golang/prometheus
* Compile the `ibmmq` component:

go get -u github.com/influxdata/influxdb/client/v2
```go install ./src/github.com/ibm-messaging/mq-golang/ibmmq```

go get -u github.com/aws/aws-sdk-go/service
* Compile the `mqmetric` component:

* Compile the components you are interested in. For example
```go install ./src/github.com/ibm-messaging/mq-golang/mqmetric```

go install ./src/github.com/ibm-messaging/mq-golang/cmd/mq_prometheus
* Use git to get a get a copy of the MQ samples metric clients in a new directory in the workspace.

At this point, you should have a compiled copy of the code in $GOPATH/bin.
```git clone https://github.com/ibm-messaging/mq-metric-samples.git src/github.com/ibm-messaging/mq-metric-samples```

* Compile the sample programs you are interested in. For example:

```go install ./src/github.com/ibm-messaging/mq-metric-samples/cmd/mq_prometheus```

At this point, you should have a compiled copy of the code in `$GOPATH/bin`.

## Limitations

Not all of the MQI verbs are available through the ibmmq package. This
Not all of the MQI verbs are available through the `ibmmq` package. This
implementation concentrates on the core API calls needed to put and get messages.
Currently unavailable verbs include:

* MQSET
* All of the message property manipulators
* MQCB
Expand All @@ -138,3 +127,7 @@ For feedback and issues relating specifically to this package, please use the [G
Contributions to this package can be accepted under the terms of the IBM Contributor License Agreement,
found in the [CLA file](CLA.md) of this repository. When submitting a pull request, you must include a statement stating
you accept the terms in the CLA.

## Copyright

© Copyright IBM Corporation 2016, 2018
Loading