Getting and setting attribute values
For many of the common attributes, the classes MQManagedObject, MQQueue, MQProcess, and MQQueueManager contain getXXX() and setXXX() methods. These methods allow you to get and set their attribute values. Note that for MQQueue, the methods work only if you specify the appropriate inquire and set flags when you open the queue.
For less common attributes, the MQQueueManager, MQQueue, and MQProcess classes all inherit from a class called MQManagedObject. This class defines the inquire() and set() interfaces.
When you create a new queue manager object by using the new operator, it is automatically opened for inquire. When you use the accessProcess() method to access a process object, that object is automatically opened for inquire. When you use the accessQueue() method to access a queue object, that object is not automatically opened for either inquire or set operations. This is because adding these options automatically can cause problems with some types of remote queues. To use the inquire, set, getXXX, and setXXX methods on a queue, specify the appropriate inquire and set flags in the openOptions parameter of the accessQueue() method.
The inquire and set methods take three parameters:
- selectors array
- intAttrs array
- charAttrs array
You do not need the SelectorCount, IntAttrCount, and CharAttrLength parameters that are found in MQINQ, because the length of an array in Java is always known. The following example shows how to make an inquiry on a queue:
// inquire on a queue final static int MQIA_DEF_PRIORITY = 6; final static int MQCA_Q_DESC = 2013; final static int MQ_Q_DESC_LENGTH = 64; int[] selectors = new int[2]; int[] intAttrs = new int[1]; byte[] charAttrs = new byte[MQ_Q_DESC_LENGTH] selectors[0] = MQIA_DEF_PRIORITY; selectors[1] = MQCA_Q_DESC; queue.inquire(selectors,intAttrs,charAttrs); System.out.println("Default Priority = " + intAttrs[0]); System.out.println("Description : " + new String(charAttrs,0));