Search code examples
javakotlinwebsphereibm-mq

work with IBM MQ from Java


I have a problem with connection in IBM MQ from java
this code

 val cf: MQQueueConnectionFactory?
    var mqConnection: QueueConnection? = null
    var session: QueueSession? = null
    var sender: QueueSender? = null
    var value = ""
    try {
        cf = MQQueueConnectionFactory()
        cf.hostName = host
        cf.port = port
        cf.queueManager = queueManager
        cf.transportType = transport
        cf.channel = channelName
        cf.clientReconnectOptions = WMQConstants.WMQ_CLIENT_RECONNECT_Q_MGR
        cf.clientReconnectTimeout = 3600

        mqConnection = cf.createQueueConnection()

drops exception "JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2035' ('MQRC_NOT_AUTHORIZED')"

when I try create connection cf.createQueueConnection()

I don't understand what is a problem.
I use ibmmq lib 9.0.2.0 version, but this code doesn't work with 7.5.0.1 version too


Solution

  • MQRC 2035 means the user doesn't have the appropriate authorities to connect to the queue manager. The reason can be found in the AMQERR*.log in the queue manager errors directory. CHLAUTH is enabled by default. You need to add CHLAUTH rules. Following link provides details on create/modify CHLAUTH

    IBM MQ 7.5.0 > WebSphere MQ > Reference > Administration reference > MQSC reference > The MQSC commands > SET CHLAUTH

    If you want more details on CHLAUTH then go through the following link:

    CHLAUTH Made Simple: Common Scenarios and Examples and How to Verify them with RUNCHECK