OW2 Consortium joram

Compare Revisions

Ignore whitespace Rev 6512 → Rev 6513

/trunk/joram/joram/tools/rest/jms/src/main/java/org/objectweb/joram/tools/rest/jms/ConsumerContext.java
26,6 → 26,7
import java.util.concurrent.ConcurrentHashMap;
 
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.Message;
 
65,7 → 66,7
return -1;
}
 
public void put(long id, Message msg) {
private final void put(long id, Message msg) {
if (msg == null)
return;
if (id > getLastId())
74,9 → 75,39
}
 
public Message getMessage(long id) {
getClientCtx().setLastActivity(System.currentTimeMillis());
return messages.get(id);
}
 
synchronized Message receive(long timeout, long msgId) throws JMSException {
Message message = null;
if (timeout > 0)
message = getConsumer().receive(timeout);
else if (timeout == 0)
message = getConsumer().receiveNoWait();
else {
message = getConsumer().receive();
if (message == null)
throw new JMSException("The consumer expire (timeout)");
}
//update activity
getClientCtx().setLastActivity(System.currentTimeMillis());
if (message != null) {
if (getJmsContext().getSessionMode() == JMSContext.CLIENT_ACKNOWLEDGE) {
long id = msgId;
if (id == -1)
id = incLastId();
put(id, message);
} else {
incLastId();
}
}
return message;
}
public Message removeMessage(long id) {
return messages.remove(id);
}