protected boolean makeRoomForMessage(int size){ if (size > this.getBufferSize()) { return false; } int freeBuffer = this.getFreeBufferSize(); int thresholdsize=0; if(size>freeBuffer) { thresholdsize=(size-freeBuffer); } else if (size==freeBuffer) { thresholdsize=size; } while (size>freeBuffer) { Message m = getThresholdMessage(thresholdsize, true); if(m==null) { return false; } deleteMessage(m.getId(), true); freeBuffer +=m.getSize(); } return true; } protected Message getThresholdMessage(int ts, boolean excludeMsgBeingSent) { Collection messages = this.getMessageCollection(); int LLM=(20*ts)/100+ts; //check least larger message(with 20%) int limit0=3600; //ttl for equal size message int limit1=3600; //ttl for least larger message Message eqMessage=null; Message lrgMessage=null; for (Message m:messages) { if(excludeMsgBeingSent && isSending(m.getId())) { continue;} if (ts==m.getSize()) { if (m.getTtl()ts ) { if (m.getTtl()