See information about the latest product version
Creating objects in a CMP application
Create new objects associated with a broker.
The following example adds an execution group called EG2 to the connected broker.
import com.ibm.broker.config.proxy.*;
public class AddExecutionGroup {
public static void main(String[] args) {
BrokerProxy b = null;
try {
BrokerConnectionParameters bcp =
new MQBrokerConnectionParameters(
"localhost",
1414,
"");
b = BrokerProxy.getInstance(bcp);
ExecutionGroupProxy e = b.createExecutionGroup("EG2");
b.disconnect();
} catch (ConfigManagerProxyException cmpex) {
System.out.println("Error connecting: "+cmpex);
}
}
}
Because requests are processed asynchronously by the broker, the ExecutionGroupProxy object that is returned from the createExecutionGroup() method is a skeleton object when it is returned to your application, because it refers to an object that might not yet exist in the broker. The application can manipulate the object as if it existed on the broker, although the actual creation of the underlying object might not happen for some time.
If the request to create the object described by the skeleton fails, all requests that use the skeleton also fail. Therefore, if execution group EG2 cannot be created, all subsequent requests that concern the skeleton object fail. However, unless the application explicitly checks for errors, it works in the same way as it does in the successful case, because no exception is thrown unless, because of a communication problem, a message cannot be sent to the broker.
See Checking the results of broker management in a CMP application for further information about how to detect problems such as these.