Tag Archives: websphere MQSeries

How to Solve IBM MQ Connect Error Code 2035

With some development experience with IBM MQ, you should realize when you look at 2035 that it was a permissions issue. The following figure

MQJE001: Completion code is '2', reason is '2035'.
Exception in thread "main" com.ibm.mq.MQException: MQJE001: Completion code is '2', reason is '2035'.
	at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:247)
	at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:588)
	at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:630)
	at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:107)
	at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:205)
	at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:911)
	at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:799)
	at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:750)
	at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:157)
	at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:681)
	at com.yusys.SendMsg.connect(SendMsg.java:30)
	at com.yusys.SendMsg.main(SendMsg.java:76)

Of course, you can also view the log file under the error folder of MQ, which has detailed error instructions.

Here is the test code:

package com.yusys;


import java.io.IOException;

import com.ibm.mq.MQEnvironment;
import com.ibm.mq.MQException;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPutMessageOptions;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.ibm.msg.client.wmq.v6.base.internal.MQC;

public class SendMsg {
	static MQQueueManager qMgr;
	static int CCSID = 1381;
	static String queueName = "RQ_0000";
	static String message;
	
	public static void connect() throws MQException{
		MQEnvironment.hostname = "172.20.35.98";
		MQEnvironment.channel = "JMS_RECEIVE";
		MQEnvironment.port = 1416;
		MQEnvironment.CCSID = CCSID;
		//User name with privileges in MQ
		MQEnvironment.userID = "MUSR_MQADMIN";
		// the password corresponding to the user name
		MQEnvironment.password = "123456";
		
		qMgr = new MQQueueManager("QMA");
	}
	
	public static void sendMsg(String msgStr){
		int openOptions = MQC.MQOO_OUTPUT|MQC.MQOO_FAIL_IF_QUIESCING;
		MQQueue queue = null;
		try {
			//Open the queue
			queue = qMgr.accessQueue(queueName, openOptions);
			// Create message buffer
			MQMessage msg = new MQMessage(); 
			//set the options for placing messages
			MQPutMessageOptions pmo = new MQPutMessageOptions();
			//the message data to be sent
			msg.format = MQC.MQFMT_STRING;
			msg.characterSet = CCSID;
			msg.encoding = CCSID;
			msg.writeString(msgStr);
			msg.expiry = -1;//Set messages to never expire
			queue.put(msg,pmo);
			qMgr.commit();
	
		} catch (MQException e) {
			e.printStackTrace();
		} catch (IOException e){
			e.printStackTrace();
		} catch (Exception e){
			e.printStackTrace();
		} finally {
			if(queue!=null){
				try {
					queue.close();
				} catch (MQException e) {
					e.printStackTrace();
				} finally{
					try {
						qMgr.disconnect();
					} catch (MQException e) {
						e.printStackTrace();
					}
				}
			}
		}
	}
	
	public static void main(String[] args) throws MQException{
		connect();
//		String msg = HttpClientUtil.doGet("http://localhost:8080/user/all");
//		sendMsg(msg);
		sendMsg("Zhuang Sheng dawned a butterfly and wished the emperor a cuckoo in spring");
		System.out.println("End of insertion");
	}
}

Usually, MQ client and MQ server communication, using the MQ server connection channel service in the MCAUSER attribute specified by the user as the MQ client even come up with the user, if the MCAUSER attribute value is empty, use the MQ client in the operating system used by the user as the MQ client even come up with the user, communication, reported a 2035 error, is due to the client and server communication used by the user without permission, there are two solutions.
Method one:
If you set the MCAUSER property to MUSR_MQADMIN(CHANNEL definition name JMS_RECEIVE) in the server’s service connection CHANNEL definition: ALTER CHANNEL(JMS_RECEIVE) CHLTYPE(SVRCONN); MCAUSER(MUSR_MQADMIN) must ensure that the MUSR_MQADMIN user is a member of the MQM group as follows:
Usermod-g GroupName Username (change the group of the existing user)
Useradd-g GroupName Username (create new user and group)
Method 2:
If MQ channel definition on the server MCAUSER attribute values for vacant province, namely is empty, the MQ client can be used by the users to add to the MQ server’s operating system, for example, if the MQ client USES for the ADMIN user, the user is added to the MQ server ADMIN, and ensure the users in the MQM group MQ the server, and how to perform the necessary permissions on the queue manager operation.

Special note: When claiming MCA authentication under Windows and finding 2035, it may be because the channel authentication record Settings are blocked. You just need to change the list of users.