Before you start
Before starting this topic, you must have completed Connecting to a Configuration Manager using the Configuration Manager Proxy.
import com.ibm.broker.config.proxy.*; public class SetLongDescription { public static void main(String[] args) { ConfigManagerProxy cmp = null; try { ConfigManagerConnectionParameters cmcp = new MQConfigManagerConnectionParameters( "localhost", 1414, ""); cmp = ConfigManagerProxy.getInstance(cmcp); } catch (ConfigManagerProxyException cmpex) { System.out.println("Error connecting: "+cmpex); } if (cmp != null) { System.out.println("Connected to Config Manager!"); describeBroker(cmp, "B1", "this is my broker"); cmp.disconnect(); } } private static void describeBroker(ConfigManagerProxy cmp, String brokerName, String newDesc) { BrokerProxy b = null; try { TopologyProxy topology = cmp.getTopology(); if (topology != null) { b = topology.getBrokerByName(brokerName); } } catch(ConfigManagerProxyPropertyNotInitializedException ex) { System.err.println("Comms problem! "+ex); } if (b != null) { try { b.setLongDescription(newDesc); } catch (ConfigManagerProxyException ex) { System.err.println("Could not send request to CM: "+ex); } } else { System.err.println("Broker "+brokerName+" not found"); } } }
Properties p = new Properties(); p.setProperty(AttributeConstants.LONG_DESCRIPTION_PROPERTY, newDesc); b.setProperties(p);
Note, that if the current user does not have the necessary permissions, as SetLongDescription.java works it is not possible to determine if the request gets rejected by the Configuration Manager. The CMP method to set the long description field throws a ConfigManagerProxyException if, and only if, the message to perform the operation can not be sent to the Configuration Manager. This means that output from the program is exactly the same, even if the Configuration Manager can not change the required property.
The reason for this is that the Configuration Manager processes requests from the CMP asynchronously, and so it could theoretically be a considerable time until the action is performed at the Configuration Manager. If methods such as the one described within this topic did not return control to the program until the completion codes became available, the performance of the CMP application would be wholly dependent on the performance of the Configuration Manager.
Next:
The design of most state-changing CMP methods is to return immediately without informing the calling application of the outcome of the request. To discover this information refer to Checking the results of broker domain management using the Configuration Manager Proxy