WebSphere Message Broker, Version 8.0.0.7 Operating Systems: AIX, HP-Itanium, Linux, Solaris, Windows, z/OS

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.

Most state-changing methods in the CMP API do not provide return code that indicates the success or failure of a specific action. For these methods, you must write different code to discover the outcome of the action. Assuming that administered objects are not shared across threads, the following code fragment can be used to discover the outcome of a request to modify a broker's LongDescription, where b is an instance of a BrokerProxy 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.

Notices | Trademarks | Downloads | Library | Support | Feedback

Copyright IBM Corporation 1999, 2016Copyright IBM Corporation 1999, 2016.

        
        Last updated:
        
        Last updated: 2016-05-23 14:47:00


Task topicTask topic | Version 8.0.0.7 | ae33080_