See information about the latest product version
Checking the results of broker management with the most recent completion code in a CMP application
Use an object's most recent completion code to determine the outcome of a request that your application made against that object.
GregorianCalendar oldCCTime =
b.getTimeOfLastCompletionCode();
b.setLongDescription(newDesc);
GregorianCalendar newCCTime = oldCCTime;
while ((newCCTime == null) || (newCCTime.equals(oldCCTime))) {
newCCTime = b.getTimeOfLastCompletionCode());
Thread.sleep(1000);
}
CompletionCodeType ccType = b.getLastCompletionCode();
if (ccType == CompletionCodeType.success) {
// etc.
}
In this example, the application initially determines when an action on the broker was last completed, using the getTimeOfLastCompletionCode() method. This method returns the time that the topology last received a completion code or, if no return codes have been received, a null value. The application updates the broker's LongDescription, then continually monitors the topology, waiting for the results of the setLongDescription() command to be returned to the CMP. When the results are returned, control breaks out of the while loop and the last completion code is determined.
As well as being unsuitable for a multi-threaded application, this algorithm for determining the outcome of commands is inefficient, because it causes the CMP application to wait while the broker processes the request.
For a more efficient application, and one that is suitable for a multi-threaded environment, code the alternative approach that uses administered object notifications; see Checking the results of broker management with object notification in a CMP application.
If you prefer, you can make property changes synchronously by using the methodBrokerProxy.setSynchronous() method. When you make synchronous property changes, methods such as setLongDescription() do not return until the change has been processed by the broker. For more information on synchronous property changes, see the description of the BrokerProxy.setSynchronous()) method in the CMP API Javadoc information.