use of com.ibm.mq.headers.MQDataException in project irontest by zheng-wang.
the class MQTeststepRunner method buildMessageFromFile.
private MQMessage buildMessageFromFile(byte[] bytes) throws MQDataException, IOException {
MQMessage message = new MQMessage();
MQMD mqmdHeader = null;
try {
mqmdHeader = new MQMD(new DataInputStream(new ByteArrayInputStream(bytes)), CMQC.MQENC_REVERSED, CMQC.MQCCSI_DEFAULT);
} catch (Exception e) {
LOGGER.info("Not able to construct MQMD out of the bytes. Exception details: ", e);
mqmdHeader = null;
}
if (mqmdHeader != null && CMQC.MQMD_STRUC_ID.equals(mqmdHeader.getStrucId()) && (CMQC.MQMD_VERSION_1 == mqmdHeader.getVersion() || CMQC.MQMD_VERSION_2 == mqmdHeader.getVersion())) {
LOGGER.info("MQMD constructed. Writing other bytes as application data.");
message.putDateTime = new GregorianCalendar();
mqmdHeader.copyTo(message);
message.persistence = CMQC.MQPER_PERSISTENT;
message.write(bytes, MQMD.SIZE2, bytes.length - MQMD.SIZE2);
} else {
LOGGER.info("No valid MQMD. Writing all bytes as application data.");
message.write(bytes);
}
return message;
}
Aggregations