This byte field contains the overall outcome of the request. This is a field of type int that is set to one of:
The following methods are available for getting some of the reply
fields:
Table 7. Getting administration reply fields
Administration field | Field type | Get method |
---|---|---|
Admin_RC | int | int getAction() |
Admin_Reason | Unicode | String getReason() |
Admin_Parms | MQeFields | MQeFields getOutputFields() |
Admin_Errors | MQeFields | MQeFields getErrorFields() |
Depending on the action performed, the only fields of interest may be the return code and reason. This is the case for delete. For other actions such as inquire, more details may be required in the reply message. For instance, if an inquire request is made for fields Queue_Description and Queue_FileDesc, the resultant MQeFields object would contain the values for the actual queue in these two fields.
The following table shows the Admin_Parms fields of a
request message and a reply message for an inquire on several parameters of a
queue:
Table 8. Enquiring on queue parameters
Admin_Parms field name | Request message | Reply message | ||
---|---|---|---|---|
Type | Value | Type | Value | |
Admin_Name | ASCII | "TestQ" | ASCII | "TestQ" |
Queue_QMgrName | ASCII | "ExampleQM" | ASCII | "ExampleQM" |
Queue_Description | Unicode | null | Unicode | "A test queue" |
Queue_FileDesc | ASCII | null | ASCII | "c:\queues\" |
For actions where no additional data is expected on the reply, the Admin_Parms field in the reply matches that of the request message. This is the case for the create and update actions.
Some actions, such as create and update, may request
that several characteristic of a managed resource be set or updated. In
this case, it is possible for a return code of RC_Mixed to be
received. Additional details indicating why each update failed are
available from the Admin_Errors field. The
following table shows an example of the Admin_Parms field
for a request to update a queue and the resultant
Admin_Errors field:
Table 9. Request and reply message to update a queue
Field name | Request message | Reply message | ||
---|---|---|---|---|
Type | Value | Type | Value | |
Admin_Parms field | ||||
Admin_Name | ASCII | "TestQ" | ASCII | "TestQ" |
Queue_QMgrName | ASCII | "ExampleQM" | ASCII | "ExampleQM" |
Queue_Description | Unicode | null | Unicode | "ExampleQM" "A new description" |
Queue_FileDesc | ASCII | null | Unicode | "D:\queues" |
Admin_Errors field | ||||
Queue_FileDesc | n/a | n/a | ASCII | "Code=4;com.ibm. mqe.MQeException: wrong field type" |
For fields where the update or set is successful there is no entry in the Admin_Errors field.
A detailed description of each error is returned in an ASCII string. The value of the error string is the exception that occurred when the set or update was attempted. If the exception was an MQeException, the actual exception code is returned along with the toString representation of the exception. So, for an MQeException, the format of the value is:
"Code=nnnn;toString representation of the exception"
This method shows how you might analyze a reply message, and return a boolean to indicate whether the action was successful or not. We take the opportunity to print out any error messages 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; }