Analyzing the reply message in Java

This method is implemented in class examples.config.BasicAdministration. It shows how you might analyze a reply message, and return whether the reply indicates that the action was successful or not. We take the opportunity to print out any error messages to the console.

   /**
    	*  Reply true if the given administration 
		* reply message represents a successful
     	* administration action.  Return false otherwise.  
		* A message indicating success
     	* or failure will be printed to the console.
     	* If the administration action was not successful 
		* then the reason will be printed
     	* to the console
     */
    public static final boolean isSuccess(MQeAdminMsg reply) 
																	throws Exception {
        boolean success = false;
        final int returnCode = reply.getRC();
        switch (returnCode) {
            case MQeAdminMsg.RC_Success:
                System.out.println("Admin succeeded");
                success = true;
                break;
            case MQeAdminMsg.RC_Fail:
                System.out.println("Admin failed, reason: 
													"+ reply.getReason());
                break;
            case MQeAdminMsg.RC_Mixed:
                System.out.println("Admin partially succeeded:\n"
                                         +reply.getErrorFields());
                break;
        }
        return success;
    }
 


© IBM Corporation 2002, 2003. All Rights Reserved