We know that MQ server could be configured such that new receiver will not be able to connect to MQ server if there is already receiver connecting to the same MQ queue. Error will look like below:
Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2042' ('MQRC_OBJECT_IN_USE')
But is there any way to configure server or client to allow new receiver to connect to MQ server and disconnect any existing receiver connection?
Below is currently how my receiver connects to server. I wonder if something could be done to setIntProperty.
cf = new MQQueueConnectionFactory();
cf.setHostName(mqHost);
cf.setPort(mqPort);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setQueueManager(mqQueueManager);
cf.setChannel(mqChannel);
conn = (MQQueueConnection) cf.createQueueConnection();
session = (MQQueueSession) conn.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
queue = (MQQueue) session.createQueue(mqQueue);
receiver = (MQQueueReceiver) session.createReceiver(queue);
Thanks!
Gerry
OK, you are mixing different concepts here. Your application is using a CLNTCONN channel to connect to the QMgr's SVRCONN channel. Yopu can have as many connections on a SVRCONN channel as memory and system resources allow. The connection is not the problem.
The '2042' ('MQRC_OBJECT_IN_USE') indicates that the program is gaining exclusive access to the queue. There are two fixes for this:
DEFSOPT value of the queue to see if it is set to EXCL or SHARED. If you need it to be sharable, make sure the queue setting reflects that.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With