Created
August 31, 2012 12:25
-
-
Save CAFxX/3552140 to your computer and use it in GitHub Desktop.
Convert IBM Websphere MQ reason codes to their human-readable description string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
import java.lang.reflect.Modifier; | |
import com.ibm.mq.constants.CMQC; | |
public class MQReasonCodes { | |
/* Use reflection on the CMQC class to fetch a human readable description of the | |
MQ reason code (e.g. getReason(2035) will return "MQRC_NOT_AUTHORIZED"). If the | |
reason code rc is not found, null will be returned */ | |
public static String getReason(int rc) { | |
for (Field f: CMQC.class.getDeclaredFields()) try { | |
if (Modifier.isStatic(f.getModifiers()) && f.getType() == int.class | |
&& f.getName().startsWith("MQRC") && f.getInt(null) == rc) | |
return f.getName(); | |
} catch (Exception e) { } | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for snippet. It helped me a lot.