Skip to content

Instantly share code, notes, and snippets.

@dangnhdev
Created January 30, 2016 14:52
Show Gist options
  • Save dangnhdev/0d750889af5a4ccae82b to your computer and use it in GitHub Desktop.
Save dangnhdev/0d750889af5a4ccae82b to your computer and use it in GitHub Desktop.
private AcmClientReqMsg getObjectFromJSon(MapMessage msg) {
try {
String msgContent = msg.getString("msgContent");
String msgType = msg.getString("msgType");
switch (msgType) {
case "MsgType1":
return gson.fromJson(msgContent, MsgType1.class);
case "MsgType2":
return gson.fromJson(msgContent, MsgType2.class);
case "MsgType3":
return gson.fromJson(msgContent, MsgType3.class);
case "MsgType4":
return gson.fromJson(msgContent, MsgType4.class);
.......
case "MsgType50":
return gson.fromJson(msgContent, MsgType50.class);
default:
logger.info("Unknown message type");
return null;
}
} catch (JMSException ex) {
logger.error("Error when consumer read message: " + ex.getMessage() + "Stack trace: ", ex);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment