Giter Site home page Giter Site logo

mq-golang's Introduction

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. With a few tiny exceptions noted below, the package implements the full-function MQI. Any application you might have written using the C or COBOL MQI ought to be easily convertible to the Go equivalent.

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.

A limited trace capability is available so you can see the MQI verbs being executed. To use this, either set the MQIGO_TRACE environment variable to any non-empty value or call the ibmmq.SetTrace(true) function.

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. You must also have a copy of MQ installed to build against. The package 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 statistics 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 was a queue manager limitation which did not permit resource publications to be made about queues whose name includes '/'. This restriction was removed in MQ 9.3. Attempting to monitor such a queue on an older queue manager results 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

mq-golang's People

Contributors

arthurbarr avatar georgijd-form3 avatar ibmmqmet avatar kalmant avatar nubenum avatar parrobe avatar riccardobiraghi avatar sdmarshall79 avatar sultrekov avatar tgulacsi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mq-golang's Issues

Suggestion: structure the repo to be more amenable to go get. Other suggestions ...

Hi,
I think the package is wonderful for Go programmers as a starting point to write Go apps that use MQ.

I'd like to suggest to re-structure the repo to be be more amenable to the go tool.
Currently the package has to be imported as:
import "github.com/ibm/messaging/mq-golang/src/mq"

With the src directory sort of implying a GOPATH. What about removing the src directory and calling the directory for the package ibmmq, or may be just keep the name as mq an call the package mq. Then the import path will match the package name, the import path will look as:
import "github.com/ibm/messaging/mq-golang/mq"

We can go even further to avoid stuttering and rename the repo to golang:

import "github.com/ibm/messaging/golang/mq"

The examples could go, as is conventional, in a separate directory:

github.com/ibm/messaging/golang/mq/ # go source code for package mq
github.com/ibm/messaging/golang/mq/cmd/mqitest/ #source code for demonstration programs.

Another suggestions is to write the comments in a form more conventional to be processed by godoc.

Also as for the design of the package it would be great if it provides higher level concepts, for instance in order to connect to the manager do something like:

mgr,err := mq.Open("mq://mqserver:1414/channel")

Is there any different process to make contributions to the code on behalf of a company instead that as individual? I work for a company that is an IBM partner and would agree to contribute the code provided that code is contributed on behalf of its name.

Thanks!

Exporter on v8 zlinux server

MQ Version - 8.0.0.9
mq-golang - v3.1.0
Go compiler - go version go1.11 linux/s390x

Trying to run Prometheus exporter on WebSphere MQ for Linux (zSeries 64-bit platform). Prometheus service starts and immediately fails with an error - MQGET: MQCC = MQCC_FAILED [2] MQRC = MQRC_NO_MSG_AVAILABLE [2033]

Is the package supported on v8 zLinux servers?

src/ibmmq/mqistr.go:25:21: error: cmqstrc.h: No such file or directory

I'm running this against IBM Websphere 8.0.1.

While trying to install mq_coll, I get the following error.

[root@sl73amsapd038 go]# go install ./src/mq_coll
ibmmq
src/ibmmq/mqistr.go:25:21: error: cmqstrc.h: No such file or directory

Looks like cmqstrc.h is supposed to be included in Websphere 8.0.0 but doesn't exist on my server (find returns nothing).

Do you know where this header should be ? How do I get it if it wasn't included as a part of the installation ?

How to get message commit time?

Hi. Thank you for providing this library. Is it possible to get the message commit timestamp ? I know that I can get PutTime easily from mqmd, but I'm looking for a way to get commit timestamp from Get method like below.

  datalen, mqreturn, err = qObject.Get(getmqmd, gmo, buffer)

Version of MQ

is there an older version of this that can be run on a V8.0.04 queue manager

Mac

Unable to compile

Please include the following information in your ticket.

  • Version information for MQ, mq-golang, Go compiler
    MQ: 9.0.0.4-IBM-MQC-Win64
    mq-golang: May 2018
    Go compiler: gcc

go version: go1.10.3 windows/386
set GOARCH=386
set GOBIN=
set GOCACHE=C:\Users\PC_ADMIN\AppData\Local\go-build
set GOEXE=.exe
set GOHOSTARCH=386
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\PC_ADMIN\go
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_386
set GCCGO=gccgo
set GO386=sse2
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\PC_AD~1\AppData\Local\Temp\go-build111339286=/tmp/go-build -gno-record-g
cc-switches

  • A small code sample that demonstrates the issue.
    I have tried compiling and i have encountered errors.
    The steps are below

C:\Users\PC_ADMIN>cd %GOPATH%

C:\Users\PC_ADMIN\go>go install .\src\github.com\ibm-messaging\mq-golang\ibmmq

github.com/ibm-messaging/mq-golang/ibmmq

C:/Program Files/IBM/MQ/bin64/mqm.dll: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status

I would be happy for any assistance

MQ Client version

When i do go install ./src/ibmmq (assuming this what want to build if want the basic MQ client go package).... I get

# ibmmq
src/ibmmq/mqiMQCNO.go:126: mqcno.CCDTUrlOffset undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlOffset)
src/ibmmq/mqiMQCNO.go:128: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:129: mqcno.CCDTUrlLength undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlLength)
src/ibmmq/mqiMQCNO.go:131: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:132: mqcno.CCDTUrlLength undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlLength)
src/ibmmq/mqiMQCNO.go:149: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:150: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)

Looked at the tagMQCNO struct in the mq includes, and do not see any struct members with Url in it. I am using MQ client linux 8.0.5. Though am a go noob.

Error down load the project from git

We are trying to execute go get -u github.com/prometheus/client_golang on a windows 7 PC. WE are getting the following error,

It appears that https://github.com/prometheus/client_golang/info/refs is a broken link.

Do ou have any insight on what we aredoing wrong.

M:\APM\mq_promo_monitoring>go get -u github.com/prometheus/client_golang

cd .; git clone https://github.com/prometheus/client_golang M:\APM\mq_promo_monitoring\src\github.com\prometheus\clien

t_golang
Cloning into 'M:\APM\mq_promo_monitoring\src\github.com\prometheus\client_golang'...
fatal: https://github.com/prometheus/client_golang/info/refs not valid: is this a git repository?
package github.com/prometheus/client_golang: exit status 128

Add NLS Support for gauge map HELP in mqmetrics

We should consider adding NLS support for the gauge map HELP field so that users can specify the human readable help description is in a specific language rather than in English.

Would require us to subscribe to two METADATA topics in order to create the gauge map:

  • The requested language to get the description to use in the HELP field
  • The default one (which is English and can be used for the metric name and as a fallback)

mq-prometheus cli help returns duplicate description for -namespace and -log.level

rob@ubuntu:~/go/bin$ ./mq_prometheus -?
flag provided but not defined: -?
Usage of ./mq_prometheus:
  -ibmmq.client
    	Connect as MQ client
  -ibmmq.httpListenPort string
    	HTTP Listener (default "9157")
  -ibmmq.httpMetricPath string
    	Path to exporter metrics (default "/metrics")
  -ibmmq.monitoredQueues string
    	Patterns of queues to monitor
  -ibmmq.monitoredQueuesFile string
    	File with patterns of queues to monitor
  -ibmmq.password string
    	Password for MQ connection
  -ibmmq.queueManager string
    	Queue Manager name
  -ibmmq.replyQueue string
    	Reply Queue to collect data (default "SYSTEM.DEFAULT.MODEL.QUEUE")
  -ibmmq.userid string
    	UserId for MQ connection
  -log.level string
    	Log level - debug, info, error (default "error")
  -metaPrefix string
    	Override path to monitoring resource topic
  -namespace string
    	Log level - debug, info, error (default "ibmmq")```

Problem is these two variables have the same description:

` -namespace string
    	Log level - debug, info, error (default "ibmmq")`
` -log.level string
    	Log level - debug, info, error (default "error")`

Connecting to multiple QMGRs

I would not say this issue , But I need some usage related information
https://www.ibm.com/developerworks/community/blogs/messaging/entry/IBM_MQ_Using_Prometheus_and_Grafana_to_montor_queue_managers?lang=en
in this example we can connect one queue manager, But how we can connect to multiple QMGRs using client connection from a centralized server ?

can I run below command multiple times for each qmgr ( I am using client connections) and diffrent Port number and can I update yaml file with differnet port numbers but same Jobname
exec /usr/local/bin/mqgo/mq_prometheus -ibmmq.queueManager=$qMgr -ibmmq.monitoredQueues="$queues" -log.level=error

Let me know if I am not clear

Build failed with undefined: mqmetric.InitChlStatistics

Go build failed with the below exceptions. As I could see the channel statistics are recently added as part of updated 905 branch. Kindly shed some light on further proceedings.

command-line-arguments

src/cmd/mq_prometheus/main.go:76: undefined: mqmetric.InitChlStatistics
The command '/bin/sh -c cd $HOME && export PATH=$PATH:/usr/local/go/bin && export GOPATH=$HOME && go build -o /usr/local/bin/mq_prometheus src/cmd/mq_prometheus/*.go' returned a non-zero code: 2

*Not-an-issue* But a query on polling queue depth

  • Version information for MQ (v9.1.0.1), mq-golang (latest), Go compiler (go1.11.3 linux/amd64)
    Thank you very much for contributing on this!

Probably a dumb question, but is there a way to scrape queue depths of queues and see it on the graphs? The use case revolves around having a) an alert to see which queues have (say 100) unprocessed messages and since how long? b) a means to identify Queues that are processing messages slowly as indicated by high/increasing queue depths.

duplicate metrics with same name and label values

MQ version: 9.0.0.3
mq-golang: Dev branch
Go: go1.11 linux/amd64

Using the mq-golang and mq-metric-samples/mq-prometheus libraries for collecting metrics. Compile and install worked fine and the exporter started with no issues. However, errors happen as below when calling the metrics endpoint -

An error has occurred during metrics collection:

5 error(s) occurred:

collected metric ibmmq_qmgr_interval_mqput_mqput1_total label:<name:"qmgr" value:"xxxxx" > gauge:<value:xxx > was collected before with the same name and label values
collected metric ibmmq_object_mqget_count label:<name:"object" value:"xxxx" > label:<name:"qmgr" value:"xxx" > gauge:<value:xx > was collected before with the same name and label values

Build or install

Hello,
i wanted to test the Prometheus metrics but when either go build or install, it fails with below:

# ibmmq
src/ibmmq/mqiMQCNO.go:153: mqcno.CCDTUrlOffset undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlOffset)
src/ibmmq/mqiMQCNO.go:155: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:156: mqcno.CCDTUrlLength undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlLength)
src/ibmmq/mqiMQCNO.go:158: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:159: mqcno.CCDTUrlLength undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlLength)
src/ibmmq/mqiMQCNO.go:186: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:187: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)

i am pretty sure i followed all steps :)

OS: Ubuntu 16.04
go version go1.6.2 linux/amd64
go version go1.7.5 linux/amd64
mq 8.0.0.4 DE
dspmqver.txt

Install on Windows 10 fails

Please include the following information in your ticket.

  • Version information for MQ, mq-golang, Go compiler
    mq-qolang: fresh clone (minutes before install attempt)
    MQ client: 9.1.0.1
    GO: go version go1.11.2 windows/amd64
  • A small code sample that demonstrates the issue.
    D:\gomq>go install ./src/github.com/ibm-messaging/mq-golang/ibmmq

runtime/cgo

gcc_libinit_windows.c: In function 'x_cgo_sys_thread_create':
gcc_libinit_windows.c:56:12: error: implicit declaration of function '_beginthread'; did you mean 'OpenThread'? [-Werror=implicit-function-declaration]
thandle = _beginthread(func, 0, arg);
^~~~~~~~~~~~
OpenThread
cc1: all warnings being treated as errors

GCC:
D:\gomq>gcc --version
gcc (GCC) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Installed via cygwin

OS:
Win 10 Pro (1803) VM on azure

fatal error: unexpected signal during runtime execution [signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x7f600d01c414]

`package main

import (
"bufio"
"fmt"
"../ibmmq"
"os"
"strings"
// "time"
)

func main() {
var qMgrName string
var qMgrObject ibmmq.MQObject
var managedQObject ibmmq.MQObject
var subObject ibmmq.MQObject
var err error
var qMgr ibmmq.MQQueueManager
// var rc int
var openOptions int32
var qObject ibmmq.MQObject

if len(os.Args) != 5 {
fmt.Println("clientconn ")
fmt.Println("")
fmt.Println("For example")
fmt.Println(" clientconn QMGR1 "SYSTEM.DEF.SVRCONN" "myhost.example.com(1414)" "LOCAL.QUEUE"")
fmt.Println("All parameters are required.")
os.Exit(1)
}

connected := false

qMgrName = os.Args[1]

cno := ibmmq.NewMQCNO()
cd := ibmmq.NewMQCD()

cd.ChannelName = os.Args[2]
cd.ConnectionName = os.Args[3]

cno.ClientConn = cd
cno.Options = ibmmq.MQCNO_CLIENT_BINDING

userId := os.Getenv("MQSAMP_USER_ID")
if userId != "" {
scanner := bufio.NewScanner(os.Stdin)
csp := ibmmq.NewMQCSP()
csp.AuthenticationType = ibmmq.MQCSP_AUTH_USER_ID_AND_PWD
csp.UserId = userId

fmt.Println("Enter password : ")
scanner.Scan()
csp.Password = scanner.Text()

cno.SecurityParms = csp

}

qMgr, err = ibmmq.Connx(qMgrName, cno)
// qMgr, err = ibmmq.Conn(qMgrName)
if err == nil {
fmt.Printf("Connection to %s succeeded.\n", qMgrName)
// d, _ := time.ParseDuration("5s")
// time.Sleep(d)
// qMgr.Disc()
} else {
fmt.Printf("Connection to %s failed.\n", qMgrName)
fmt.Println(err)
}

if err == nil {
mqod := ibmmq.NewMQOD()

openOptions = ibmmq.MQOO_OUTPUT + ibmmq.MQOO_FAIL_IF_QUIESCING
openOptions |= ibmmq.MQOO_INPUT_AS_Q_DEF

mqod.ObjectType = ibmmq.MQOT_Q
mqod.ObjectName = os.Args[4]

qObject, err = qMgr.Open(mqod, openOptions)
if err != nil {
    fmt.Println(err)
} else {
    fmt.Println("Opened queue", qObject.Name)
}

}

if err == nil {
putmqmd := ibmmq.NewMQMD()
pmo := ibmmq.NewMQPMO()

pmo.Options = ibmmq.MQPMO_SYNCPOINT | ibmmq.MQPMO_NEW_MSG_ID | ibmmq.MQPMO_NEW_CORREL_ID

putmqmd.Format = "MQSTR"
msgData := "Hello from Go"
buffer := []byte(msgData)

// mqod := ibmmq.NewMQOD()
// openOptions = ibmmq.MQOO_INQUIRE + ibmmq.MQOO_FAIL_IF_QUIESCING
// mqod.ObjectType = ibmmq.MQOT_CHANNEL
// mqod.ObjectName = qObject.Name
err = qObject.Put(putmqmd, pmo, buffer)
// err = qMgr.Put1(mqod, putmqmd, pmo, buffer)

if err != nil {
    fmt.Println(err)
} else {
    fmt.Println("Put message to", qObject.Name)
}

}

if err == nil {
err = qMgr.Cmit()
if err != nil {
fmt.Println(err)
}
}

if err == nil {
msgAvail := true

for msgAvail == true {
    var datalen int

    getmqmd := ibmmq.NewMQMD()
    gmo := ibmmq.NewMQGMO()
    gmo.Options = ibmmq.MQGMO_NO_SYNCPOINT | ibmmq.MQGMO_FAIL_IF_QUIESCING
    gmo.Options |= ibmmq.MQGMO_WAIT
    gmo.WaitInterval = 3000
    buffer := make([]byte, 32768)

    datalen, err = qObject.Get(getmqmd, gmo, buffer)

    if err != nil {
        msgAvail = false
        fmt.Println(err)
        mqret := err.(*ibmmq.MQReturn)
        if mqret.MQRC == ibmmq.MQRC_NO_MSG_AVAILABLE {
            err = nil
        }
    } else {
        fmt.Printf("Got message of length %d: ", datalen)
        fmt.Println(strings.TrimSpace(string(buffer[:datalen])))
    }
}

}

if err == nil {
err = qObject.Close()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Closed queue")
}
}

if err == nil {
mqsd := ibmmq.NewMQSD()
mqsd.Options = ibmmq.MQSO_CREATE
mqsd.Options |= ibmmq.MQSO_NON_DURABLE
mqsd.Options |= ibmmq.MQSO_FAIL_IF_QUIESCING
mqsd.Options |= ibmmq.MQSO_MANAGED
mqsd.ObjectString = "$SYS/MQ/INFO/QMGR/" + qMgrName + "/ActivityTrace/ApplName/mqitest"

subObject, err = qMgr.Sub(mqsd, &managedQObject)

if err != nil {
    fmt.Println(err)
} else {
    fmt.Println("Subscribed to topic ", mqsd.ObjectString)
}

}

if err == nil {
msgAvail := true

for msgAvail == true {
    var datalen int

    getmqmd := ibmmq.NewMQMD()
    gmo := ibmmq.NewMQGMO()
    gmo.Options = ibmmq.MQGMO_NO_SYNCPOINT | ibmmq.MQGMO_FAIL_IF_QUIESCING
    gmo.Options |= ibmmq.MQGMO_WAIT
    gmo.WaitInterval = 3000
    buffer := make([]byte, 32768)

    datalen, err = managedQObject.Get(getmqmd, gmo, buffer)

    if err != nil {
        msgAvail = false
        fmt.Println(err)
        mqret := err.(*ibmmq.MQReturn)
        if mqret.MQRC == ibmmq.MQRC_NO_MSG_AVAILABLE {
            // not a real error so reset err, but
            // end retrieval loop
            err = nil
        }
    } else {
        fmt.Printf("Got message of length %d. Format = %s\n", datalen, getmqmd.Format)
    }
}

}

if err == nil {
subObject.Close()
}

if err == nil {
mqod := ibmmq.NewMQOD()
openOptions = ibmmq.MQOO_INQUIRE + ibmmq.MQOO_FAIL_IF_QUIESCING

mqod.ObjectType = ibmmq.MQOT_Q_MGR
mqod.ObjectName = qMgrName

qMgrObject, err = qMgr.Open(mqod, openOptions)

if err != nil {
    fmt.Println(err)
} else {
    fmt.Printf("Opened QMgr for MQINQ\n")
}

}

if err == nil {
selectors := []int32{ibmmq.MQCA_Q_MGR_NAME,
ibmmq.MQCA_DEAD_LETTER_Q_NAME,
ibmmq.MQIA_MSG_MARK_BROWSE_INTERVAL}

intAttrs, charAttrs, err := qMgrObject.Inq(selectors, 2, 160)

if err != nil {
    fmt.Println(err)
} else {
    returnedName := string(charAttrs[0:48])
    fmt.Printf("MQINQ returned +%v %s \n",
        intAttrs, string(charAttrs))
    fmt.Printf("               '%s'\n", returnedName)
}

}

if connected {
err = qMgr.Disc()
fmt.Println("Disconnected from queue manager ", qMgrName)
}

if err == nil {
os.Exit(0)
} else {
mqret := err.(*ibmmq.MQReturn)
os.Exit((int)(mqret.MQCC))
}

}`

But it get the following error:
`> [root@localhost clientconn]# ./clientconn QM_T01 "JMS" "127.0.0.1(1414)" "LQ"
Connection to QM_T01 succeeded.
Opened queue LQ
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x7f214ba2b414]

runtime stack: runtime.throw(0x4ebdce, 0x2a)
/home/app/go/src/runtime/panic.go:605 +0x95 runtime.sigpanic()
/home/app/go/src/runtime/signal_unix.go:351 +0x2b8

goroutine 1 [syscall, locked to thread]: runtime.cgocall(0x49ed30,
0xc42004f9c8, 0x100) /home/app/go/src/runtime/cgocall.go:132 +0xe4
fp=0xc42004f980 sp=0xc42004f940 pc=0x4072c4
_/svr/ibmmq/ibmmq._Cfunc_MQPUT(0x1000006, 0xc42007c000, 0xc4200720c0, 0xd, 0xc420016110, 0xc420016120, 0xc4200160fc)
_/svr/ibmmq/ibmmq/_obj/_cgo_gotypes.go:887 +0x45 fp=0xc42004f9c8
sp=0xc42004f980 pc=0x4938e5
_/svr/ibmmq/ibmmq.MQObject.Put.func1(0x1000006, 0xc42007c000, 0xc4200720c0, 0xc40000000d, 0xc420016110, 0xc420016120, 0xc4200160fc)
/svr/ibmmq/ibmmq/mqi.go:407 +0x10e fp=0xc42004fa10 sp=0xc42004f9c8
pc=0x49a69e
_/svr/ibmmq/ibmmq.MQObject.Put(0x0, 0xc42000c0a0, 0xc42001a0f0, 0x30, 0xc420078000, 0xc42007a000, 0xc420016110, 0xd, 0x10, 0x0, ...)
/svr/ibmmq/ibmmq/mqi.go:407 +0x120 fp=0xc42004fa80 sp=0xc42004fa10
pc=0x495030 main.main() /svr/ibmmq/clientconn/clientconn.go:102
+0x158e fp=0xc42004ff80 sp=0xc42004fa80 pc=0x49e29e runtime.main() /home/app/go/src/runtime/proc.go:195 +0x226 fp=0xc42004ffe0
sp=0xc42004ff80 pc=0x42e9c6 runtime.goexit()
/home/app/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc42004ffe8
sp=0xc42004ffe0 pc=0x457491`

Support for New Relic reporting

I am working on adding another option for reporting the collected data (send to New Relic). How should I proceed? Should I just send a PR?

mq-golang and mqmetric build

Dear ibm-messaging team,

I'm trying to build mq-golang and mqmetric from the following trees. However, the instructions provided in README files are provided in the below git URLs are not working as is.

I see the directory structure I have (source is downloaded through "Clone or Download" button) doesn't match with what is provided in the build instructions.

Is there a way to download already compiled binaries? That will really help OR any reference to build instruction also will do. Please do the needful. Thanks in advance.

When will it be compatible with 7.5?

Please include the following information in your ticket.

  • Version information for MQ, mq-golang, Go compiler
  • A small code sample that demonstrates the issue.

Monitoring HA

MQ - v9.0.0.2
mq-golang - v3.0.1
Go - 1.11

Is there any impact on the monitor program if HA (Active/Active) is enabled on Prometheus?

go1.11 MQRC_SSL_INITIALIZATION_ERROR

Do you have any mq-golang samples for TLS connection? I am getting error MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_SSL_INITIALIZATION_ERROR [2393]

var mqcno = mq.NewMQCNO()
mqcno.Options = mq.MQCNO_CLIENT_BINDING

var mqcd = mq.NewMQCD()
mqcd.ChannelName = "XYZ.SVRCONN"
mqcd.ConnectionName = "server.com(1414)"
mqcd.SSLCipherSpec = "TLS_RSA_WITH_NULL_SHA256"
mqcd.CertificateLabel = "ibmwebspheremqxxxx"
mqcd.SSLClientAuth = mq.MQSCA_REQUIRED
mqcno.ClientConn = mqcd

var mqsco = mq.NewMQSCO()
mqsco.KeyRepository = "C:\\mqm\\ssl\\key"
mqsco.CertificateLabel = "ibmwebspheremqxxxx"
mqcno.SSLConfig = mqsco


var qmgr mq.MQQueueManager
qmgr, err = mq.Connx("QM1", mqcno)
if err != nil {
	fmt.Printf("Failed connecting to MQ host/manager. %s \n", err.Error())
	return
}
defer qmgr.Disc()
fmt.Printf("MQ host/manager connected \n")

Can you give an example of how to use the connx method?

I used mqitest.go code, and made some changes

	gocno := ibmmq.NewMQCNO()
	gocno.Options = 0x00000080
	gocno.CCDTUrl = "mq.test.com(1486)"
        qMgr, mqreturn, err := ibmmq.Connx(qMgrName, gocno)
     or  ` gocno.CCDTUrl = "file:///xxx/ccdt.TAB"`

go run mqitest.go
The results are as follows

MQCONN: MQCC = MQCC_FAILED [2] MQRC = MQRC_Q_MGR_NAME_ERROR [2058]

I want to connect to a remote queue manager
Can you give an example of how to use the Connx method?

monitor queue manager on prometheus

Hi
I am new to the premtheus tool.
I have installed MQ on windows.
I have installed docker tool box on same path. In docker, i have ran prometheus and grafana docker images.
I can able to access mq objects and perform mqsc commands in dcoker too.
but i need to know how to monitor queue manager from prometheus.
Can you please provide information on this.
crtmqm in docker

Metrics from z/OS

Does the current version of go-lang libraries support pulling metrics from z/OS v8? We are looking to leverage the QSTATUS and CHSTATUS commands.

Does this work with MQ8

Is it possible to make this work with MQ8 by reading the statistics out of the queue rather than subscribing to it (as in MQ9)

mq_prometheus scale up issue

From mq-metric-samples created by sagar123ramesh : ibm-messaging/mq-metric-samples#4

We are trying to leverage mq_prometheus for monitoring and statistics
purpose against MQ 9 QMGRs. The mq metrics samples has been downloaded
from github (master copy)

https://github.com/ibm-messaging/mq-metric-samples

and mq_prometheus has been built for RHEL 7, and successfully able to
connect to the QMGR instance and subscribe to system topics to collect
the stats.

However, observed a challenge in scaling up when tried to monitor
number of queues by using the supported pattern (*asterisk).

For example:

/local/umbuild/prometheus/mq_prometheus -ibmmq.queueManager=NAUMQ02 -

ibmmq.
monitoredQueuesFile=/var/mqm/qmgrs/NAUMQ02/config/mq_prometheus_queues -
log.level=error

While the queues to be monitored are listed in file
/var/mqm/qmgrs/NAUMQ02/config/mq_prometheus_queues as follows

cat /var/mqm/qmgrs/NAUMQ02/config/mq_prometheus_queues

PERFTEST.QUEUE.*
PERFTEST.QUEUE.666
PERFTEST.QUEUE.777

In the PoC environment we have, the pattern PERFTEST.QUEUE.* resolves
into 2000 Queues, in this case the mq_prometheus fails to inquire all
the queues due to in-sufficient output buffer, and gets the TRUNCATED
message.

When I looked at the code github.com/ibm-messaging/mq-
golang/mqmetric/discover.go where discover() function is implemented,
the code just allocates around 32KB chunk of memory, and also mentions
about hitting the TRUNCATED message error.

I just tried increasing the buffer size to accommodate more than 2000
Queues, recompiled the mq_prometheus and deployed.

This resolves the TRUNCATED message error, however mq_promethues will
hit the MAXHANDS (default 256) limits at QMGR level as mq_prometheus
opens at least 4 subscription handles (one each for OPENCLOSE, PUT,
GET, SETINQ) for each Queues to be monitored.

TOPICSTR($SYS/MQ/INFO/QMGR/NAUMQ02/Monitor/STATQ/PERFTEST.QUEUE.
1001/GET)
TOPICSTR($SYS/MQ/INFO/QMGR/NAUMQ02/Monitor/STATQ/PERFTEST.QUEUE.
1001/OPENCLOSE)
TOPICSTR($SYS/MQ/INFO/QMGR/NAUMQ02/Monitor/STATQ/PERFTEST.QUEUE.
1001/PUT)
TOPICSTR($SYS/MQ/INFO/QMGR/NAUMQ02/Monitor/STATQ/PERFTEST.QUEUE.
1001/INQSET)

To overcome this, changed the MAXHANDS (10000), then mq_prometheus
succeeds. Relate to this have couple of questions.

1.Is there a plan (in near term) to address the TRUNCATED message
issue? i.e., by allocating the memory in loop OR providing an
environment variable to mention size of buffer?
2.What is the implication of increasing the MAXHANDS to higher value,
in terms of system resource configuration or kernel parameter
settings? The scope of the MAXHANDS is per connection, but in real
production environment where thousands of client connections are active
we need to make sure those client connections doesnt suffer in terms
of resources.
3.Can the number of handles be reduced by subscribing to higher level
of the topic string? example: Instead of 4 listed above, subscribe to
$SYS/MQ/INFO/QMGR/NAUMQ02/Monitor/STATQ/PERFTEST.QUEUE.1001 to get all
4 key value pair and process it.

type *C.struct_tagMQCNO has no field or method CCDTUrlOffset

compiling against MQv8.0.0.6, see the following when trying to install the plugin

go install ./src/mq_coll

# ibmmq
src/ibmmq/mqiMQCNO.go:153: mqcno.CCDTUrlOffset undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlOffset)
src/ibmmq/mqiMQCNO.go:155: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:156: mqcno.CCDTUrlLength undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlLength)
src/ibmmq/mqiMQCNO.go:158: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:159: mqcno.CCDTUrlLength undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlLength)
src/ibmmq/mqiMQCNO.go:186: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)
src/ibmmq/mqiMQCNO.go:187: mqcno.CCDTUrlPtr undefined (type *C.struct_tagMQCNO has no field or method CCDTUrlPtr)

Struct defined in src/ibmmq/mqiMQCNO.go with type string. Not familiar with golang but perhaps the type shouldn't be string ?

type MQCNO struct {
Version       int32
Options       int32
SecurityParms *MQCSP
CCDTUrl       string
ClientConn    *MQCD
SSLConfig     *MQSCO
}

Used @153:

mqcno.CCDTUrlOffset = 0

mqmetric - example needed

Hi Mark,

Can you give an example on how to use the metric lib for meassuring the queue depth? You have done a great job here but there is almost no sample code on how to use these libs. I think it will be very benificial for the project and for newcomers to understand how to use it. Don't you agree?

BR
Mathias

Missing -rpath in mqi.go LDFLAGS

Currently, LDFLAGS in mqi.go do not specify -rpath:

https://github.com/ibm-messaging/mq-golang/blob/master/ibmmq/mqi.go#L40

MQ docs recommend using -rpath for linking, and indeed when it's absent it's a bit painful: the executable can't run unless LD_LIBRARY_PATH is set (normally by source /opt/mqm/bin/setmqenv -sk or similar). Unfortunately, it doesn't seem to work reliably for services, e.g. trigger monitors.

I am not sure how it can be best addressed. Would just setting 64-bit lib for default MQ installation be better than now? Like

#cgo !windows LDFLAGS: -L/opt/mqm/lib64 -Wl,-rpath=/usr/lib64 -lmqm_r

I will be probably forking your library to set it for me for the time being, I haven't found another option. Any ideas?

Thanks for your support!

Question: build error

Please include the following information in your ticket.

  • Version information for MQ, mq-golang, Go compiler
    IBMMQ:WS_MQ_V7.5.0.2_TRIAL_FOR_WINDOWS_ML (X86)
    mq-golang: download from master
    go:go version go1.10 windows/amd64
  • A small code sample that demonstrates the issue.
    $ go install ./src/cmd/mq_prometheus/*.go

modify mqi.go file :

#cgo !windows CFLAGS: -I/opt/mqm/inc -D_REENTRANT
#cgo windows CFLAGS: -I"D:/ProgramFiles/IBM/WebSphereMQ/tools/c/include"
#cgo !windows LDFLAGS: -L/opt/mqm/lib64 -lmqm_r -Wl,-rpath=/opt/mqm/lib64 -Wl,-rpath=/usr/lib64
#cgo windows LDFLAGS: -L "D:/ProgramFiles/IBM/WebSphereMQ/bin64" -lmqm

build result:

ibmmq

In file included from src\ibmmq\mqi.go:57:0:
D:/ProgramFiles/IBM/WebSphereMQ/tools/c/include/cmqc.h:3584:10: error: unknown type name '_int64'
typedef _int64 MQINT64;
^~~~~~
D:/ProgramFiles/IBM/WebSphereMQ/tools/c/include/cmqc.h:3585:26: error: expected '=', ',', ';', 'asm' or 'attribute' before 'MQUINT64'
typedef unsigned _int64 MQUINT64;
^~~~~~~~
D:/ProgramFiles/IBM/WebSphereMQ/tools/c/include/cmqc.h:3610:10: error: unknown type name 'MQUINT64'
typedef MQUINT64 MQPOINTER PMQUINT64;
^~~~~~~~

Prometheus cant load MQ metrics using mq_prometheus

I have followed the guide how to build the mq_prometheus metric collector.
When running it on a MQ 9.0.5 server it connects to the MQ QMGR but somehow it wont gather any metrics to prometheus.
Im running on RHEL 7.4, IBM MQServer 9.0.5.0.

The mq_prometheus binary is built on a CentOS 7.5.1804 with mq-golong v2.0.0 (tried both dev-branch and master) and using Go v1.9.4.

The mq_prometheus starts with this command:
./mq_prometheus -ibmmq.queueManager PTGLA01 -ibmmq.monitoredQueues EBCDEVSEC01 -log.level debug

The output from this is looking all good, listing all gauges and ending with:

INFO[0000] IBMMQ Describe started
INFO[0000] Listening on 9157
INFO[0056] IBMMQ Collect started

However ibmmq is not available in Prometheus.
Checking targets shows:

ibmmq (0/1 up)
Endpoint State Labels Last Scrape Error
http://localhost:9157/metrics
down instance="localhost:9157" 24.541s ago server returned HTTP status 500 Internal Server Error

Doing some debuging with promtool:

Output is 2 different errors:

curl -s http://localhost:9157/metrics | ./promtool check metrics

  • error while linting: text format parsing error in line 1: expected float as value, got "error"
  • http_request_duration_microseconds use base unit "seconds" instead of "microseconds"

Can you please help me out here?
I feel I have tried everything!

Br
Jonas Wennberg

Temporary queue filling up

MQ - v9.1
mq-golang - v3.0.1
Go - 1.11

Temporary queue is created when Prometheus service is started and filling up in no time. Why is a temporary queue created?

panic: MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_ENVIRONMENT_ERROR [2012]

package main

import (
  "fmt"

  "github.com/ibm-messaging/mq-golang/ibmmq"
)

func connectToQueue(qMgrName string, channelName string, connectionName string, username string, password string) (ibmmq.MQObject, ibmmq.MQQueueManager) {
  var openOptions int32
  var qObject ibmmq.MQObject

  cno := ibmmq.NewMQCNO()
  cd := ibmmq.NewMQCD()
  csp := ibmmq.NewMQCSP()

  csp.AuthenticationType = ibmmq.MQCSP_AUTH_USER_ID_AND_PWD
  csp.UserId = username
  csp.Password = password

  cd.ChannelName = channelName
  cd.ConnectionName = connectionName

  cno.ClientConn = cd
  cno.Options = ibmmq.MQCNO_CLIENT_BINDING
  cno.SecurityParms = csp

  qMgr, err := ibmmq.Connx(qMgrName, cno)

  if err != nil {
    panic(err)
  }

  mqod := ibmmq.NewMQOD()

  openOptions = ibmmq.MQOO_OUTPUT + ibmmq.MQOO_FAIL_IF_QUIESCING
  openOptions |= ibmmq.MQOO_INPUT_AS_Q_DEF

  mqod.ObjectType = ibmmq.MQOT_Q
  mqod.ObjectName = "ObjectName"

  qObject, err = qMgr.Open(mqod, openOptions)

  if err != nil {
    panic(err)
  }

  return qObject, qMgr
}

func putMessageOnQueue(qObject ibmmq.MQObject, qMgr ibmmq.MQQueueManager, msgData string, msgId string, correlId string, replyToQueueName string) {
  var err error

  putmqmd := ibmmq.NewMQMD()
  pmo := ibmmq.NewMQPMO()

  pmo.Options = ibmmq.MQPMO_SYNCPOINT | ibmmq.MQPMO_NEW_MSG_ID | ibmmq.MQPMO_NEW_CORREL_ID

  putmqmd.Format = "MQSTR"
  putmqmd.MsgId = []byte(msgId)
  putmqmd.CorrelId = []byte(correlId)
  putmqmd.ReplyToQ = replyToQueueName
  buffer := []byte(msgData)

  err = qObject.Put(putmqmd, pmo, buffer)

  if err != nil {
    panic(err)
  }

  err = qMgr.Cmit()

  if err != nil {
    panic(err)
  }
}

func getMessageFromQueue(qObject ibmmq.MQObject, queueName string, correlId string) {
  var err error

  var datalen int

  getmqmd := ibmmq.NewMQMD()
  getmqmd.CorrelId = []byte(correlId)

  gmo := ibmmq.NewMQGMO()
  gmo.Options = ibmmq.MQGMO_NO_SYNCPOINT | ibmmq.MQGMO_FAIL_IF_QUIESCING
  gmo.Options |= ibmmq.MQGMO_WAIT
  gmo.WaitInterval = 3000

  buffer := make([]byte, 32768)

  datalen, err = qObject.Get(getmqmd, gmo, buffer)

  if err != nil {
    panic(err)
  }

  fmt.Println("%d", datalen)
}

func disconnectFromQueue(qObject ibmmq.MQObject, qMgr ibmmq.MQQueueManager) {
  var err error

  err = qObject.Close(0)

  if err != nil {
    panic(err)
  }

  err = qMgr.Disc()

  if err != nil {
    panic(err)
  }
}

func main() {
  queueManager := ""
  channelName := "redacted"
  connectionName := "redacted(1416)"
  username := "redacted"
  password := "redacted"

  qObject, qMgr := connectToQueue(queueManager, channelName, connectionName, username, password)

  putMessageOnQueue(qObject, qMgr, "TEST", "msgId", "correlId")

  getMessageFromQueue(qObject, "correlId")

  disconnectFromQueue(qObject, qMgr)
}
brandon@debian:~$ uname -a
Linux debian 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux

Ran git clone https://github.com/ibm-messaging/mq-golang.git src/github.com/ibm-messaging/mq-golang today as per README so library is most up to date.

/opt/mqm has IBM_MQ_SDK-9.0.0

mqmetrics package could prevent queue manager stopping

We set the necessary options for each queue to fail if the queue manager is quiescing. However the processpublications will ignore the return code that the queue manager sends if it wants to shutdown MQRC_Q_MGR_QUIESCING.

This means if you run endmqm -w <qmname> your queue manager will never stop.

Segfault in amqscb

Hey Folks,

Here is the environment information:

$ go version
go version go1.11.4 linux/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/userx/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/userx/work/golang"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/golang"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/userx/work/golang/src/github.com/<cut>/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build420169263=/tmp/go-build -gno-record-gcc-switches"
$ gcc --version
gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6)
$ dspmqver
Name:        IBM MQ
Version:     9.1.0.1
Level:       p910-001-181108
BuildType:   IKAP - (Production)
Platform:    IBM MQ for Linux (x86-64 platform)
Mode:        64-bit
O/S:         Linux 4.19.14-300.fc29.x86_64
InstName:    Installation1
InstDesc:    
Primary:     No
InstPath:    /opt/mqm
DataPath:    /var/mqm
MaxCmdLevel: 910

The issue:

  • Build amqscb from master
  • Run

Expected result:

  • Consume some messages from given queue

Actual result:

  • Segfault

Logs:

Sample AMQSCB.GO start
Connected to queue manager QM1
Opened queue DEV.QUEUE.1
signal 11 received but handler not on signal stack
fatal error: non-Go code set up signal handler without SA_ONSTACK flag

runtime stack:
runtime: unexpected return pc for runtime.sigtramp called from 0x7f13cf1aae67
stack: frame={sp:0xc00004e4a8, fp:0xc00004e500} stack=[0xc0000463f8,0xc00004e7f8)
000000c00004e3a8:  000000c00004e3b0  00000000004550d0 <runtime.throw.func1+0> 
000000c00004e3b8:  00000000004e906f  0000000000000039 
000000c00004e3c8:  000000c00004e3e8  000000000044113f <runtime.sigNotOnStack+127> 
000000c00004e3d8:  00000000004e906f  0000000000000039 
000000c00004e3e8:  000000c00004e498  0000000000440974 <runtime.sigtrampgo+788> 
000000c00004e3f8:  000000000000000b  000000c00004e480 
000000c00004e408:  000000c00004e700  0000000000000000 
000000c00004e418:  0000000000000000  000000c00004e4a8 
000000c00004e428:  0000000000000000  0000000000000000 
000000c00004e438:  0000000000000000  0000000000000000 
000000c00004e448:  0000000000000000  000000c000000780 
000000c00004e458:  0000000000000000  0000000000000000 
000000c00004e468:  0000000000000000  0000000000000000 
000000c00004e478:  0000000000000000  000000c000042000 
000000c00004e488:  0000000000000000  0000000000008000 
000000c00004e498:  000000c00004e4f0  000000000045a023 <runtime.sigtramp+67> 
000000c00004e4a8: <000000000000000b  000000c00004e830 
000000c00004e4b8:  000000c00004e700  000000c00004e700 
000000c00004e4c8:  000000c00004e830  0000000000000001 
000000c00004e4d8:  000000000000000b  000000c00004e4f0 
000000c00004e4e8:  00007f13cfb313c0  0000000000f39e20 
000000c00004e4f8: !00007f13cf1aae67 >0000000000000000 
000000c00004e508:  0000000000000000  0000000000000000 
000000c00004e518:  0000000000000000  0000000000000000 
000000c00004e528:  0000000000000000  0000000000000000 
000000c00004e538:  0000000000000000  0000000000000000 
000000c00004e548:  0000000000000000  0000000000000000 
000000c00004e558:  0000000000000000  0000000000000000 
000000c00004e568:  0000000000000000  0000000000000000 
000000c00004e578:  0000000000000000  0000000000000000 
000000c00004e588:  0000000000000000  0000000000000000 
000000c00004e598:  0000000000f39e20  000000c00004edd0 
000000c00004e5a8:  0000000000000008  0000000000000011 
000000c00004e5b8:  00000000004f5654  0000000000000000 
000000c00004e5c8:  00007f13cf1ab665  0000000041534d58 
000000c00004e5d8:  000000000000000b  0000000000000000 
000000c00004e5e8:  0000000000000000  000000c00004e690 
000000c00004e5f8:  0000000000000000 
runtime.throw(0x4e906f, 0x39)
        /usr/lib/golang/src/runtime/panic.go:608 +0x72
runtime.sigNotOnStack(0xb)
        /usr/lib/golang/src/runtime/signal_unix.go:576 +0x7f
runtime.sigtrampgo(0xb, 0xc00004e830, 0xc00004e700)
        /usr/lib/golang/src/runtime/signal_unix.go:334 +0x314
runtime: unexpected return pc for runtime.sigtramp called from 0x7f13cf1aae67
stack: frame={sp:0xc00004e4a8, fp:0xc00004e500} stack=[0xc0000463f8,0xc00004e7f8)
000000c00004e3a8:  000000c00004e3b0  00000000004550d0 <runtime.throw.func1+0> 
000000c00004e3b8:  00000000004e906f  0000000000000039 
000000c00004e3c8:  000000c00004e3e8  000000000044113f <runtime.sigNotOnStack+127> 
000000c00004e3d8:  00000000004e906f  0000000000000039 
000000c00004e3e8:  000000c00004e498  0000000000440974 <runtime.sigtrampgo+788> 
000000c00004e3f8:  000000000000000b  000000c00004e480 
000000c00004e408:  000000c00004e700  0000000000000000 
000000c00004e418:  0000000000000000  000000c00004e4a8 
000000c00004e428:  0000000000000000  0000000000000000 
000000c00004e438:  0000000000000000  0000000000000000 
000000c00004e448:  0000000000000000  000000c000000780 
000000c00004e458:  0000000000000000  0000000000000000 
000000c00004e468:  0000000000000000  0000000000000000 
000000c00004e478:  0000000000000000  000000c000042000 
000000c00004e488:  0000000000000000  0000000000008000 
000000c00004e498:  000000c00004e4f0  000000000045a023 <runtime.sigtramp+67> 
000000c00004e4a8: <000000000000000b  000000c00004e830 
000000c00004e4b8:  000000c00004e700  000000c00004e700 
000000c00004e4c8:  000000c00004e830  0000000000000001 
000000c00004e4d8:  000000000000000b  000000c00004e4f0 
000000c00004e4e8:  00007f13cfb313c0  0000000000f39e20 
000000c00004e4f8: !00007f13cf1aae67 >0000000000000000 
000000c00004e508:  0000000000000000  0000000000000000 
000000c00004e518:  0000000000000000  0000000000000000 
000000c00004e528:  0000000000000000  0000000000000000 
000000c00004e538:  0000000000000000  0000000000000000 
000000c00004e548:  0000000000000000  0000000000000000 
000000c00004e558:  0000000000000000  0000000000000000 
000000c00004e568:  0000000000000000  0000000000000000 
000000c00004e578:  0000000000000000  0000000000000000 
000000c00004e588:  0000000000000000  0000000000000000 
000000c00004e598:  0000000000f39e20  000000c00004edd0 
000000c00004e5a8:  0000000000000008  0000000000000011 
000000c00004e5b8:  00000000004f5654  0000000000000000 
000000c00004e5c8:  00007f13cf1ab665  0000000041534d58 
000000c00004e5d8:  000000000000000b  0000000000000000 
000000c00004e5e8:  0000000000000000  000000c00004e690 
000000c00004e5f8:  0000000000000000 
runtime.sigtramp(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /usr/lib/golang/src/runtime/sys_linux_amd64.s:353 +0x43

goroutine 34 [syscall, locked to thread]:
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc0000cefe8 sp=0xc0000cefe0 pc=0x458441

goroutine 1 [sleep]:
fatal error: unexpected signal during runtime execution
panic during panic
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x44d78b]

runtime stack:
runtime: unexpected return pc for runtime.sigtramp called from 0x7f13cf1aae67
stack: frame={sp:0xc00004e4a8, fp:0xc00004e500} stack=[0xc0000463f8,0xc00004e7f8)
000000c00004e3a8:  000000c00004e3b0  00000000004550d0 <runtime.throw.func1+0> 
000000c00004e3b8:  00000000004e906f  0000000000000039 
000000c00004e3c8:  000000c00004e3e8  000000000044113f <runtime.sigNotOnStack+127> 
000000c00004e3d8:  00000000004e906f  0000000000000039 
000000c00004e3e8:  000000c00004e498  0000000000440974 <runtime.sigtrampgo+788> 
000000c00004e3f8:  000000000000000b  000000c00004e480 
000000c00004e408:  000000c00004e700  0000000000000000 
000000c00004e418:  0000000000000000  000000c00004e4a8 
000000c00004e428:  0000000000000000  0000000000000000 
000000c00004e438:  0000000000000000  0000000000000000 
000000c00004e448:  0000000000000000  000000c000000780 
000000c00004e458:  0000000000000000  0000000000000000 
000000c00004e468:  0000000000000000  0000000000000000 
000000c00004e478:  0000000000000000  000000c000042000 
000000c00004e488:  0000000000000000  0000000000008000 
000000c00004e498:  000000c00004e4f0  000000000045a023 <runtime.sigtramp+67> 
000000c00004e4a8: <000000000000000b  000000c00004e830 
000000c00004e4b8:  000000c00004e700  000000c00004e700 
000000c00004e4c8:  000000c00004e830  0000000000000001 
000000c00004e4d8:  000000000000000b  000000c00004e4f0 
000000c00004e4e8:  00007f13cfb313c0  0000000000f39e20 
000000c00004e4f8: !00007f13cf1aae67 >0000000000000000 
000000c00004e508:  0000000000000000  0000000000000000 
000000c00004e518:  0000000000000000  0000000000000000 
000000c00004e528:  0000000000000000  0000000000000000 
000000c00004e538:  0000000000000000  0000000000000000 
000000c00004e548:  0000000000000000  0000000000000000 
000000c00004e558:  0000000000000000  0000000000000000 
000000c00004e568:  0000000000000000  0000000000000000 
000000c00004e578:  0000000000000000  0000000000000000 
000000c00004e588:  0000000000000000  0000000000000000 
000000c00004e598:  0000000000f39e20  000000c00004edd0 
000000c00004e5a8:  0000000000000008  0000000000000011 
000000c00004e5b8:  00000000004f5654  0000000000000000 
000000c00004e5c8:  00007f13cf1ab665  0000000041534d58 
000000c00004e5d8:  000000000000000b  0000000000000000 
000000c00004e5e8:  0000000000000000  000000c00004e690 
000000c00004e5f8:  0000000000000000 
runtime.throw(0x4e831b, 0x2a)
        /usr/lib/golang/src/runtime/panic.go:608 +0x72
runtime.sigpanic()
        /usr/lib/golang/src/runtime/signal_unix.go:374 +0x2f2
runtime.gentraceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc000000300, 0x0, 0x0, 0x64, 0x0, 0x0, 0x0, ...)
        /usr/lib/golang/src/runtime/traceback.go:249 +0x155b
runtime.traceback1(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc000000300, 0x0)
        /usr/lib/golang/src/runtime/traceback.go:728 +0xf3
runtime.traceback(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xc000000300)
        /usr/lib/golang/src/runtime/traceback.go:682 +0x52
runtime.tracebackothers(0xc0000be180)
        /usr/lib/golang/src/runtime/traceback.go:947 +0x187
runtime.dopanic_m(0xc0000be180, 0x42de02, 0xc00004e3a8, 0x1)
        /usr/lib/golang/src/runtime/panic.go:805 +0x2aa
runtime.fatalthrow.func1()
        /usr/lib/golang/src/runtime/panic.go:663 +0x5f
runtime.fatalthrow()
        /usr/lib/golang/src/runtime/panic.go:660 +0x57
runtime.throw(0x4e906f, 0x39)
        /usr/lib/golang/src/runtime/panic.go:608 +0x72
runtime.sigNotOnStack(0xb)
        /usr/lib/golang/src/runtime/signal_unix.go:576 +0x7f
runtime.sigtrampgo(0xb, 0xc00004e830, 0xc00004e700)
        /usr/lib/golang/src/runtime/signal_unix.go:334 +0x314
runtime: unexpected return pc for runtime.sigtramp called from 0x7f13cf1aae67
stack: frame={sp:0xc00004e4a8, fp:0xc00004e500} stack=[0xc0000463f8,0xc00004e7f8)
000000c00004e3a8:  000000c00004e3b0  00000000004550d0 <runtime.throw.func1+0> 
000000c00004e3b8:  00000000004e906f  0000000000000039 
000000c00004e3c8:  000000c00004e3e8  000000000044113f <runtime.sigNotOnStack+127> 
000000c00004e3d8:  00000000004e906f  0000000000000039 
000000c00004e3e8:  000000c00004e498  0000000000440974 <runtime.sigtrampgo+788> 
000000c00004e3f8:  000000000000000b  000000c00004e480 
000000c00004e408:  000000c00004e700  0000000000000000 
000000c00004e418:  0000000000000000  000000c00004e4a8 
000000c00004e428:  0000000000000000  0000000000000000 
000000c00004e438:  0000000000000000  0000000000000000 
000000c00004e448:  0000000000000000  000000c000000780 
000000c00004e458:  0000000000000000  0000000000000000 
000000c00004e468:  0000000000000000  0000000000000000 
000000c00004e478:  0000000000000000  000000c000042000 
000000c00004e488:  0000000000000000  0000000000008000 
000000c00004e498:  000000c00004e4f0  000000000045a023 <runtime.sigtramp+67> 
000000c00004e4a8: <000000000000000b  000000c00004e830 
000000c00004e4b8:  000000c00004e700  000000c00004e700 
000000c00004e4c8:  000000c00004e830  0000000000000001 
000000c00004e4d8:  000000000000000b  000000c00004e4f0 
000000c00004e4e8:  00007f13cfb313c0  0000000000f39e20 
000000c00004e4f8: !00007f13cf1aae67 >0000000000000000 
000000c00004e508:  0000000000000000  0000000000000000 
000000c00004e518:  0000000000000000  0000000000000000 
000000c00004e528:  0000000000000000  0000000000000000 
000000c00004e538:  0000000000000000  0000000000000000 
000000c00004e548:  0000000000000000  0000000000000000 
000000c00004e558:  0000000000000000  0000000000000000 
000000c00004e568:  0000000000000000  0000000000000000 
000000c00004e578:  0000000000000000  0000000000000000 
000000c00004e588:  0000000000000000  0000000000000000 
000000c00004e598:  0000000000f39e20  000000c00004edd0 
000000c00004e5a8:  0000000000000008  0000000000000011 
000000c00004e5b8:  00000000004f5654  0000000000000000 
000000c00004e5c8:  00007f13cf1ab665  0000000041534d58 
000000c00004e5d8:  000000000000000b  0000000000000000 
000000c00004e5e8:  0000000000000000  000000c00004e690 
000000c00004e5f8:  0000000000000000 
runtime.sigtramp(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /usr/lib/golang/src/runtime/sys_linux_amd64.s:353 +0x43

How to use application after build?

Hi!
After build application and runing with other PC there is an error MQRC 2277.

Environment is possibly not correctly set. How it is correct to launch? MQ Client is set.

Question : MQ Package to Publish / Subscribe to IBM MQ 

I need to publish / subscribe to IBM MQ queues / topics (v8.0.0.4 fixpack, so currently no AMQP support). Unfortunately I don't have the luxury of building against an instance of IBM MQ, as I'm working in a containerized environment.

Is there support for communicating to IBM MQ from a containerized, isolated Go application that's supported by other languages such as Java? The IBM post here uses this library as the go-to package for communicating with IBM MQ, but if you can't be isolated from the instance, it's usage is quite hindered. I'm curious if I just need the header files, like the previous mq-golang library was doing, to get this package to work or to be able to write a simple library to communicate with IBM MQ.

If this is not supported by this package and if anyone can direct me to an implementation where I can simply communicate with IBM MQ while being separated from where the instance is deployed, I would greatly appreciate it. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.