Checking the results of broker domain management using the Configuration Manager Proxy with return codes

This is part of the larger task of developing Configuration Manager Proxy (CMP) applications.

The only state-changing methods that supply a return code representing the outcome of the request are the deploy() methods. The following sample of code shows how to discover the outcome of a topology deploy operation using the returned DeployResult object:
...

TopologyProxy t = cmp.getTopology();

boolean isDelta = true;
long timeToWaitMs = 10000;
DeployResult dr = topology.deploy(isDelta, timeToWaitMs);

System.out.println("Overall result = "+dr.getCompletionCode());

// Display overall log messages
Enumeration logEntries = dr.getLogEntries();
while (logEntries.hasMoreElements()) {
    LogEntry le = (LogEntry)logEntries.nextElement();
    System.out.println("General message: " + le.getDetail());
}
            
// Display broker specific information
Enumeration e = dr.getDeployedBrokers();
while (e.hasMoreElements()) {
                
    // Discover the broker
    BrokerProxy b = (BrokerProxy)e.nextElement();
    
    // Completion code for broker
    System.out.println("Result for broker "+b+" = " +
        dr.getCompletionCodeForBroker(b));
                
    // Log entries for broker
    Enumeration e2 = dr.getLogEntriesForBroker(b);
    while (e2.hasMoreElements()) {
        LogEntry le = (LogEntry)e2.nextElement();
        System.out.println("Log message for broker " + b +
            le.getDetail()));
    }
}

In this code the deploy() method is blocked until all affected brokers have responded to the deployment request. However, the method includes a long parameter that describes the maximum length of time the CMP waits for the responses to arrive.

Note that when the method finally returns, the DeployResult represents the outcome of the deployment at the time the method returned. In other words, once returned to the application, the object is not updated by the CMP.

After the deploy() method completes, the example interrogates the returned DeployResult and displays the overall completion code for the deploy operation. This takes one of the following values:
(com.ibm.broker.config.proxy.)CompletionCodeType.pending
Means that the deploy is held in a batch and is not sent until you issue ConfigManagerProxy.sendUpdates(). Note that if this message applies it is returned immediately – that is, without waiting for the timeout period to expire.
CompletionCodeType.submitted
Means that the deploy message was sent to the Configuration Manager but no response was received before the timeout occurred. Note that if the deployment message can not be sent to the Configuration Manager, a ConfigManagerProxyLoggedException is thrown at deploy time instead.
CompletionCodeType.initiated
Means that the Configuration Manager replied stating that deployment has started, but no broker responses were received before the timeout occurred.
CompletionCodeType.successSoFar
Means that the Configuration Manager issued the deployment request and some, but not all, brokers responded with a "success" message before the timeout period expired. No brokers responded negatively.
CompletionCodeType.success
Means that the Configuration Manager issued the deployment request, and all relevant brokers responded successfully before the timeout period expired. This message is sent as soon as all relevant brokers have responded successfully.
CompletionCodeType.failure
Means that the Configuration Manager issued the deployment request, and at least one broker responded negatively.
Note, that not all completion codes apply to all deploys. For example, deploying to a single specific broker cannot result in a completion code of 'successSoFar'.

The example next displays any log messages from the deployment that can not be attributed to any specific broker. On a successful deploy, these messages always include a "deploy initiated" log entry originating from the Configuration Manager, even if the deployment subsequently completed.

Finally, the example displays the completion code and any log messages specific to each broker affected by the deployment. Note that on a topology or topic tree deploy, this is every broker in the domain.

The set of completion codes applicable to a response from a specific broker are:
CompletionCodeType.pending
Means that the deploy is held in a batch and is not sent until you issue ConfigManagerProxy.sendUpdates().
CompletionCodeType.submitted
Means that the deploy message was sent but no response has yet been received from the Configuration Manager stating that deployment has been initiated.
CompletionCodeType.initiated
Means that the Configuration Manager has replied, stating that deployment has started, but no reply has yet been returned from the broker.
CompletionCodeType.success
Means that the Configuration Manager issued the deployment request, and the broker successfully applied the deployment changes.
CompletionCodeType.failure
Means that the Configuration Manager issued the deployment request, and the broker responded by stating that the deployment was not successful. Use getLogEntriesForBroker() for more information on why the deployment failed.
CompletionCodeType.notRequired
Means that a deployment request was submitted to the Configuration Manager that involved the supplied broker, but the broker was not sent the request because its configuration is already up to date.
See Running the Deploy BAR sample or Running the broker domain management sample CMPAPIExerciser.reportDeployResult() method for examples of how to parse DeployResult objects.
Related tasks
Checking the results of broker domain management using the Configuration Manager Proxy
Checking the results of broker domain management using the Configuration Manager Proxy with the last completion code
Checking the results of broker domain management using the Configuration Manager Proxy with object notification