Checking the results of integration node management with the most recent completion code by using a custom integration application

Use an object's most recent completion code to determine the outcome of a request that your application made against that object.

About this task

Most state-changing methods in the IBM® Integration 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.

The following code example shows how to view the outcome of a request to modify the LongDescription of the integration node, 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.
}
Note: This code assumes that administered objects are not shared across threads.

In this example, the application initially determines when an action on the integration node was last completed, by using the getTimeOfLastCompletionCode() method. This method returns the time that the topology last received a completion code or, if no return codes were received, a null value. The application updates the integration node's LongDescription, then continually monitors the topology, waiting for the results of the setLongDescription() command to be returned to the IBM Integration API. When the results are returned, control breaks out of the while loop and the last completion code is determined.

This algorithm for determining the outcome of commands is inefficient, because it causes the custom integration application to wait while the integration node processes the request. The algorithm is also not suited for multi-threading.

For a more efficient application, and one that is suitable for a multi-threaded environment, code an alternative approach that uses administered object notifications; see Checking the results of integration node management with object notification by using a custom integration 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 is processed by the integration node. For more information about synchronous property changes, see the description of the BrokerProxy.setSynchronous()) method in the IBM Integration API Javadoc information (IBM Integration API).