}
MessageInfo storeMessage(Packet message, ConsumerUID[] iids, int[] states,
boolean sync) throws IOException, BrokerException {
SysMessageID id = message.getSysMessageID();
// just check the cached map; all messages should be
// loaded before this is called
if (messageMap.containsKey(id)) {
logger.log(logger.ERROR, br.E_MSG_EXISTS_IN_STORE, id, myDestination);
throw new BrokerException(
br.getString(br.E_MSG_EXISTS_IN_STORE, id, myDestination));
}
try {
int msgsize = message.getPacketSize();
MessageInfo info = null;
if (vrfile != null &&
(maxRecordSize == 0 || msgsize < maxRecordSize)) {
// store in vrfile
info = new MessageInfo(this, vrfile, message, iids, states, sync);
} else {
// store in individual file
info = new MessageInfo(this, message, iids, states, sync);
}
// cache it, make sure to use the cloned SysMessageID
messageMap.put(info.getID(), info);
// increate destination message count and byte count
incrMsgCount(msgsize);
return info;
} catch (IOException e) {
logger.log(logger.ERROR, br.X_PERSIST_MESSAGE_FAILED,
id.toString(), e);
throw e;
}
}