ibm-messaging / mq-golang

Calling IBM MQ from Go applications
Apache License 2.0
168 stars 60 forks source link

Exiting: MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_RESOURCE_PROBLEM [2102] #139

Closed jochen1234 closed 4 years ago

jochen1234 commented 4 years ago

Hi Mark,

I have update my GO Beat Code to a new version of "github.com/ibm-messaging/mq-golang/ibmmq". Afterwards I get the error code Exiting: MQCONNX: MQCC = MQCC_FAILED [2] MQRC = MQRC_RESOURCE_PROBLEM [2102]. Your example works.

/ Prepare mq client / func connectMqQueue(bt *Mqbeat) error { debugf("msb-beat -> connectMqQueue -> entry.")

var err error
var mqreturn *ibmmq.MQReturn

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

logp.Info("msb-beat -> connectMqQueue -> set mq connection channel %s.", bt.config.ChannelName)
cd.ChannelName = bt.config.ChannelName

logp.Info("msb-beat -> connectMqQueue -> set mq host(port) %s.", bt.config.ConnectionName)
cd.ConnectionName = bt.config.ConnectionName

// Reference the CD structure from the CNO
// and indicate that we want to use the client
// connection method.
cno.ClientConn = cd
cno.ApplName = "Golang 9.1.2 ApplName"

if bt.config.IsClient == true {
    logp.Info("msb-beat -> connectMqQueue -> set mq binding to client.")
    cno.Options = ibmmq.MQCNO_CLIENT_BINDING

    csp.AuthenticationType = ibmmq.MQCSP_AUTH_USER_ID_AND_PWD

    logp.Info("msb-beat -> connectMqQueue -> set mq client user name %s.", bt.config.UserId)
    csp.UserId = bt.config.UserId

    logp.Info("msb-beat -> connectMqQueue -> set mq client user password.")
    csp.Password = bt.config.Password

    // And make the CNO refer to the CSP structure
    cno.SecurityParms = csp
} else {
    logp.Info("msb-beat -> connectMqQueue -> set mq binding to server.")
    cno.Options = ibmmq.MQCNO_SHARED_BINDING
}

cno.Options |= ibmmq.MQCNO_HANDLE_SHARE_BLOCK

// And connect. Wait a short time before
// disconnecting.
bt.qMgr, err = ibmmq.Connx(bt.config.QmgrName, cno)

if err == nil {
    logp.Info("msb-beat -> connectMqQueue -> connection to qmgr %s succeeded.", bt.config.QmgrName)

    mqod := ibmmq.NewMQOD()

    logp.Info("msb-beat -> connectMqQueue -> try to open queue %s.", bt.config.QueueName)

    mqod.ObjectName = bt.config.QueueName
    goOpenOptions.Options = ibmmq.MQOO_FAIL_IF_QUIESCING + ibmmq.MQOO_INPUT_SHARED

    bt.queue, err = bt.qMgr.Open(mqod, goOpenOptions.Options)

    if err == nil {
        logp.Info("msb-beat -> connectMqQueue -> queue %s opened.", bt.config.QueueName)
    } else {
        mqreturn = err.(*ibmmq.MQReturn)
        logp.Err("msb-beat -> connectMqQueue -> open queue %s failed with: %s.", bt.config.QueueName, mqreturn)
    }
} else {
    mqreturn = err.(*ibmmq.MQReturn)

    logp.Err("msb-beat -> connectMqQueue -> connection to qmgr %s failed with: %s.\n", bt.config.QmgrName, mqreturn)
}

debugf("msb-beat -> connectMqQueue -> exit.")

return err

}

[admin@localhost mqbeat]$ go version go version go1.13.7 linux/amd64

[admin@localhost mqbeat]$ /opt/mqm/bin/dspmqver Name: IBM MQ Version: 9.1.4.0 Level: p914-L191119 BuildType: IKAP - (Production) Platform: IBM MQ for Linux (x86-64 platform) Mode: 64-bit O/S: Linux 3.10.0-1062.12.1.el7.x86_64 O/S Details: CentOS Linux 7 (Core) InstName: Installation1 InstDesc:
Primary: No InstPath: /opt/mqm DataPath: /var/mqm MaxCmdLevel: 914 LicenseType: Production

jochen1234 commented 4 years ago
fs.inotify.max_user_watches=524288

kernel.shmmni=4096
kernel.shmall=209715
kernel.sem=4096
kernel.sem=128
kernel.threads-max=32768
kernel.pid_max=32768

fs.file-max=524288

#*               soft    core            0
#*               hard    rss             10000
#@student        hard    nproc           20
#@faculty        soft    nproc           20
#@faculty        hard    nproc           50
#ftp             hard    nproc           0
#@student        -       maxlogins       4

mqm       hard  nofile     10240
mqm       soft  nofile     10240
mqm       hard  nproc      4096
mqm       soft  nproc      4096
ibmmqmet commented 4 years ago

For that RC I'd normally expect there to be an FDC file created or something in one of the AMQERRxx.LOG files that gives more information.

jochen1234 commented 4 years ago

errors.tar.gz Here the files

jochen1234 commented 4 years ago

Hi Mark,

here the solution. If anyone wants to mq golang with libbeat 7.x he has to disable seccomp in the beat configuration.

https://www.elastic.co/guide/en/beats/filebeat/master/linux-seccomp.html

seccomp.enabled: false

ibmmqmet commented 4 years ago

Well found. I wouldn't have thought of that. Might be interesting to see which specific system calls could be added to the default policy rather than a blanket disablement, but that's always likely to be empirical - rarely-taken paths in the code might expose additional system calls.