• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 8 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Calling IBM MQ from Go applications

mq-golang

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

The repository originally also contained programs that exported MQ statistics to monitoring systems. These programs have been moved to a GitHub repository called mq-metric-samples.

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.

Health Warning

This package is provided as-is with no guarantees of support or updates. You cannot use IBM formal support channels (Cases/PMRs) for assistance with material in this repository.

There are also no guarantees of compatibility with any future versions of the package; the API is subject to change based on any feedback. Versioned releases are made in this repository to assist with using stable APIs. Future versions will follow semver guidance so that breaking changes will only be done with a new major version number on the module.

See the DEPRECATIONS file for any planned changes to the API.

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.

Sample programs are provided to demonstrate various features of using the MQI. See the 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 documentation. Although that doesn't mention Go as a language, the principles for all applications apply.

The mqmetric directory contains functions to help monitoring programs access MQ status and statistics. This package is not needed for general application programs.

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 this would be /opt/mqm) but this can be changed with environment variables if necessary.

Windows compatibility is also included. Current versions of the Go compiler permit 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.

MQ Client SDK

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 Windows).

For Linux x64 and Windows systems, you may also choose to use the MQ Redistributable Client package which is a simple zip/tar file that does not need any privileges to install:

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 git client and the gcc C compiler

Windows

  • Install the Go runtime and compiler. On Windows, the common directory is c:\Go
  • Ensure you have a gcc-based compiler. The variant that seems to be recommended for cgo is the tdm-gcc-64 64-bit compiler suite. The default gcc compiler from Cygwin does not work because it tries to build a Cygwin-enabled executable but the MQ libraries do not work in that model; the mingw versions build Windows-native programs.
  • Create a working directory. For example, mkdir c:\Gowork
  • Set an environment variable for the compiler
set CC=x86_64-w64-mingw32-gcc.exe

Common

  • Make sure your PATH includes routes to the Go compiler, the Git client, and the C compiler.

  • Change to the directory you created earlier.

  • Use git to get a copy of the MQ components into a new directory in the workspace.

    git clone [email protected]:ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang

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

For example, on Linux:

   export MQ_INSTALLATION_PATH=/my/mq/dir  # This will also be set from the setmqenv command
   export CGO_CFLAGS="-I$MQ_INSTALLATION_PATH/inc"
   export CGO_LDFLAGS="-L$MQ_INSTALLATION_PATH/lib64 -Wl,-rpath,$MQ_INSTALLATION_PATH/lib64"

Or on Windows:

  set CGO_CFLAGS=-Ic:\IBM-MQC-Redist-Win64\tools\c\include -D_WIN64
  set CGO_LDFLAGS=-L c:\IBM-MQC-Redist-Win64\bin64 -lmqm
  • Sample programs can be compiled directly:
cd src/github.com/ibm-messaging/mq-golang/samples
go build -o /tmp/mqitest mqitest/*.go

At this point, you should have a compiled copy of the program in /tmp. See the samples directory for more sample programs.

Building in a container

The buildSamples.sh script in this directory can also be used to create a container which will install the MQ Client SDK, compile the samples and copy them to a local directory. If you use this approach, you do not need to install a local copy of the compiler and associated tools, though you will still need a copy of the MQ C client runtime libraries for wherever you execute the programs.

Go Modules

The packages in this repository are set up to be used as Go modules. See the go.mod file in the root of the repository.

Support for modules started to be introduced around Go 1.11 and has been firmed up in various modification level updates in each of the compiler levels since then. It is now recommended to use at least version 1.17 of the compiler.

Use of modules means that packages do not need to be independently compiled or installed. Environment variables such as GOROOT and GOPATH that were previously required are now redundant in module mode.

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

  require (
    github.com/ibm-messaging/mq-golang/v5 v5.x.y
  )

and your application code includes

  import ibmmq "github.com/ibm-messaging/mq-golang/v5/ibmmq"

If you have not moved to using modules in your application, you should continue using the older levels of these packages. For example, you can continue to use dep with Gopkg.toml referring to

[[constraint]]
  name = "github.com/ibm-messaging/mq-golang"
  version = "4.1.4"

Those older versions are not maintained, so it is strongly recommended you do move to using modules.

Related Projects

These GitHub-hosted projects are related to or derived from this one. This is not a complete list. Please let me know, via an issue, if you have another project that might be suitable for inclusion here.

Repository Description
ibm-messaging/mq-metric-samples Extracts metrics for use in Prometheus, Influx
JSON consumers etc.
ibm-messaging/mq-golang-jms20 JMS-style messaging interface for Go applications
ibm-messaging/mq-container Building MQ into containers. Uses features from this package
for configuration and monitoring
felix-lessoer/qbeat Extract monitoring and statstics from MQ for use in Elasticsearch
ibm-messaging/mq-mqi-nodejs A similar MQI interface for Node.js applications

Limitations

Package 'ibmmq'

  • All regular MQI verbs are available through the ibmmq package.
  • The only unimplemented area of MQI function is the use of Distribution Lists: they were rarely used, and the Publish/Subscribe operations provide similar capability.
  • Go is not supported for writing MQ Exits, so structures and methods for those features are not included.

Package 'mqmetric'

  • 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.
  • 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.

History

See CHANGELOG in this directory.

Issues and Contributions

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

For feedback and issues relating specifically to this package, please use the GitHub issue tracker.

Contributions to this package can be accepted under the terms of the Developer's Certificate of Origin, found in the DCO file of this repository. When submitting a pull request, you must include a statement stating you accept the terms in the DCO.

Copyright

© Copyright IBM Corporation 2016, 2023

More Repositories

1

mq-container

Container images for IBM® MQ
Go
212
star
2

mq-dev-patterns

Code samples and messaging patterns for IBM MQ developers
JavaScript
181
star
3

mq-jms-spring

Components to assist MQ JMS integration with Spring frameworks
Java
177
star
4

mq-docker

[DEPRECATED] Sample Docker image for IBM® MQ
Shell
125
star
5

event-streams-samples

Java
91
star
6

kafka-connect-mq-source

This repository contains a Kafka Connect source connector for copying data from IBM MQ into Apache Kafka.
Java
86
star
7

mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
JavaScript
74
star
8

mq-dev-samples

Samples for getting started with IBM MQ
Java
62
star
9

mq-metric-samples

IBM® MQ metric gathering client samples
Go
58
star
10

kafka-java-vertx-starter

Starter Java app for testing connection to Apache Kafka with Vert.x
JavaScript
44
star
11

mq-rfhutil

Message creation, editing and replay to help test MQ and IIB/ACE applications. Previously released as IH03 RFHUTIL SupportPac
C++
42
star
12

kafka-connect-jdbc-sink

This repository contains a Kafka Connect sink connector for copying data from Apache Kafka into databases using JDBC.
Java
34
star
13

mqtt-ios-sample

Sample iOS app using MQTT
Objective-C
34
star
14

mq-ansible

Ansible roles for IBM MQ
Python
30
star
15

mq-helm

Smarty
28
star
16

kafka-connect-mq-sink

This repository contains a Kafka Connect sink connector for copying data from Apache Kafka into IBM MQ.
Java
28
star
17

mq-golang-jms20

JMS style messaging interface for Golang applications connecting to IBM MQ
Go
26
star
18

mqperf

Repository for MQ related performance documents
22
star
19

mqlight-docker

Docker image for IBM MQ Light
Shell
22
star
20

mq-aws

Sample code for running IBM® MQ on Amazon Web Services (AWS)
Shell
21
star
21

kafka-connect-rabbitmq-source

This repository contains a Kafka Connect source connector for copying data from RabbitMQ into Apache Kafka.
Java
19
star
22

message-hub-rest

JavaScript
17
star
23

mq-q-qload

This repository contains the code from IBM MQ SupportPacs MA01 (q) and MO03 (qload)
C
17
star
24

mqtt-PickMeUp

Objective-C
16
star
25

mq-dev-badge-sample

Sample code of the MQ developer essentials badge
HTML
13
star
26

mq-chef

Chef cookbook for installing and configuring IBM® MQ
Ruby
13
star
27

mq-container-mft

Samples for integrating MQ MFT in Cloud scenarios
Go
13
star
28

mq-azure

This repository contains information and samples etc. relating to using IBM MQ on Microsoft Azure
Shell
12
star
29

mq-rdqm

Repository for the Replicated Data Queue Manager feature of IBM MQ
PowerShell
11
star
30

mq-tls-ssl-wizard

A wizard to help configure your MQ SSL/TLS connections
Java
11
star
31

mq-cph

The IBM MQ C Performance Harness
C++
10
star
32

mq-rexx-api

A REXX interface to issue MQ API calls - previously known as Supportpac MA95
C
9
star
33

mq-mqsc-editor-plugin

A plug-in for the MQ Explorer to help edit and execute MQSC scripts
HTML
8
star
34

mq-exits

A collection of sample IBM MQ exits
C
8
star
35

mqldt

IBM MQ Log Disk Tester
C
8
star
36

mq-appliance

This repository contains information and samples relating to the IBM MQ Appliance
Perl
7
star
37

mq-camel

A place for samples that describes IBM MQ and Apache Camel integration
Java
7
star
38

mq-openstack

Sample code for running IBM® MQ on OpenStack
Shell
6
star
39

kafka-connect-ibmcos-sink

This repository contains a Kafka Connect sink connector for copying data from Apache Kafka into IBM Cloud Object Storage
Java
6
star
40

mqlight-fishalive-node

Node.js MQ Light fishalive sample
JavaScript
6
star
41

jmstestp

Environment for creating a docker image running jms performance tests for Persistent and Non Persistent messaging.
Shell
6
star
42

mq-mft

Repository for IBM MQ Managed File Transfer documents, samples etc
Java
6
star
43

mq-event-display

Java
6
star
44

mq-cloud-demo

Sample scenario and applications for demonstrating the IBM MQ on Cloud service
JavaScript
6
star
45

mq-dotnet-administration-with-mqrestapi

This repository provides .NET samples which help in doing basic IBM MQ Queue/Channel Administration using IBM MQ REST API's
C#
6
star
46

cphtestp

Environment for creating a docker image running cph performance tests for Persistent and Non-Persistent messaging against an MQ Queue Manager.
Shell
6
star
47

mq-smf-csv

Simple formatter for MQ's SMF records to assist with import to spreadsheets and databases
C
6
star
48

mq-dotnet-samples

C#
5
star
49

cp4i-mq-samples

Samples to showcase connecting to a queue manager running as part of IBM Cloud Pak for Integration
Shell
5
star
50

macaque

Flask style library for microservices with MQ Light
Python
5
star
51

mq-cluster-tool

A tool to query and visualize your IBM MQ Clusters using a graph
Java
5
star
52

mq-atom-mqsc

Repository for the MQSC syntax hightlighting code used in the Atom text editor
5
star
53

kafka-connect-xml-converter

A Kafka Connect plugin to make it easier to work with XML data in Kafka Connect pipelines
Java
5
star
54

kafka-connect-elastic-sink

Kafka Connector to deliver events into Elasticsearch
Java
4
star
55

mq-wlm-client

Java
4
star
56

seneca-mqlight-transport

DEPRECATED: Implementation of a transport layer for using MQ Light with the Seneca microservices framework
JavaScript
4
star
57

mft-sample-web-ui

IBM MQ Managed File Transfer REST API
JavaScript
4
star
58

mq-python-json

Repo showing example(s) of how to consume and parse MQ event messages in Python
Python
4
star
59

mqlight-worker-thread

This repository contains a lab based on the worker thread use case for MQ Light
JavaScript
4
star
60

mq-sample-web-ui

A sample web page that uses the MQ administrative REST API
JavaScript
4
star
61

event-streams-docs

4
star
62

mq-asyncapi-java-template

This repository is no longer used and the project is now hosted within the ASyncAPI organisation.
JavaScript
4
star
63

ms03.saveqmgr

ms03-saveqmgr
C
3
star
64

mqlight-sentiment-sample

Files for MQ Light Lab at Impact
PHP
3
star
65

mqtt-smartboard

Java
3
star
66

mq-rexx-utils

This tool provides rexx execs to take output from CSQUTIL or runmqsc and create HTML pages so you can compare and contrast the differences on MQ object and their attributes. Differences are highlighted. You can display all attributes, or just different attributes.
HTML
3
star
67

mqlight-python-bluemix

MQ Light Python sample for Bluemix
HTML
3
star
68

mq-ansible-yaml-commands

IBM MQ Ansible Collection to issue YAML form commands to MQ queue managers
2
star
69

mq-ssl

This repository will contain a Wiki describing how to configure SSL with MQ in a couple of scenarios.
2
star
70

mq-pvc-tool

A tool for inspecting the Persistent Volume Claims associated with Queue Manager pods on OpenShift
Shell
2
star
71

mq-mi

Repository for information, samples etc. relating to IBM MQ Multi Instance queue manager support
C
2
star
72

mq-sfbridge-demo

IBM MQ Salesforce bridge demo in Docker
Shell
2
star
73

mqlight-fishalive-ruby

Ruby MQ Light fishalive sample
HTML
2
star
74

mqldt-c

Containerized version of mqldt
Dockerfile
2
star
75

mqtt-home-automation

This repository will contain an example of using MQTT to publish information about a house and controlling some aspects by publishing MQTT messages
2
star
76

iperf3-client

Configuration to build and run iperf3 client images
Dockerfile
2
star
77

ibm-messaging.github.io

WebSite for IBM Messaging
CSS
2
star
78

mq-ibmcloud

Sample code for running IBM® MQ on IBM Cloud (e.g. Bluemix / SoftLayer)
Java
2
star
79

mq-scratch-extension

Repo hosting the ScratchX.org extension for IBM MQ using the IBM MQ REST API
JavaScript
2
star
80

mq-mqfts

IBM MQ Managed File Transfer Log Capture Utility
Go
2
star
81

mqtt-status-pattern

This repository contains an example showing a pattern of usage of MQTT that makes available the status of MQTT clients.
C
2
star
82

kafka-connect-weather-source

This repository contains a Kafka Connect source connector for importing data from the IBM Weather Service into Apache Kafka.
Java
2
star
83

MFT-REST-java-sample

Java
2
star
84

homebrew-ibmmq

Homebrew tap for IBM MQ formulae and casks
Ruby
2
star
85

mq-mft-file-ordering

File Ordering MQMFT Exit
Java
1
star
86

mq-mft-REST-Samples

Go
1
star
87

iperf3-server

Configuration to build iperf3 images
Dockerfile
1
star
88

mq-raspberry-pi-developers

1
star
89

event-streams-operator-resources

1
star
90

mqtt-android-helper

Java
1
star
91

mqlight-fishalive-java

Java MQ Light fishalive sample
Java
1
star
92

mqlight-interconnect-2015-lab

Materials for the MQ Light Interconnect 2015 lab
HTML
1
star
93

messagesight-oauth-sample

Java
1
star
94

mqlight-conference-lab

Materials for demonstrating the use of the MQ Light API at conferences
HTML
1
star
95

mq-uniform-clusters

MQ Uniform Clusters bring a set of queue managers together to work as a single unit to intelligently distribute the applications across them. This repository provides simple scripts and setup to get going quickly
C
1
star
96

messagesight-message-expiry

This repository contains an example of using JMS to publish a message to MessageSight with a time to live and seeing that applied when there is an MQTT subscriber.
Java
1
star