Administration message Java™ examples - 2

This method shows how you might analyze a reply message, and return a boolean to indicate whether or not the action was successful. Error messages are printed to the console.

/**
*Reply true if the given admin reply 
*message represents a successful
*admin action.Return false otherwise.
*A message indicating success
*or failure will be printed to the console.
*If the admin 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:
    /* all on one line */
        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;
}

Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.