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