Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MQSeries - Any setting to allow new receiver to take over connection?

Tags:

java

ibm-mq

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

like image 783
Gerry Avatar asked Dec 18 '25 15:12

Gerry


1 Answers

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:

  1. Don't use exclusive access to the queue. Check the 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.
  2. If you need the queue to remain exclusive (for example because messages are sequence dependent), stop the previous connection before attempting a new connection. When a program does not close a connection gracefully, an orphaned channel agent holds the connection's queues open. Eventually the agent times out and any exclusive input queues become available again. If programs are leaving orphaned channels, fix the programs. As a short-term measure, you can manually stop orphaned channels to release the lock on the input queue.
like image 70
T.Rob Avatar answered Dec 21 '25 05:12

T.Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!