*/
private List getMessages(int nb, String selector, boolean remove) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Queue.getMessages(" + nb + ',' + selector + ',' + remove + ')');
List lsMessages = new ArrayList();
Message message;
int j = 0;
// Checking the deliverable messages:
while ((lsMessages.size() < nb || nb == -1) && j < messages.size()) {
message = (Message) messages.get(j);
// If selector matches, sending the message:
if (Selector.matches(message.getHeaderMessage(), selector) &&
checkDelivery(message.getHeaderMessage())) {
message.incDeliveryCount();
nbMsgsDeliverSinceCreation++;
// use in sub class see ClusterQueue
messageDelivered(message.getIdentifier());
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Message " + message.getIdentifier());
lsMessages.add(message);
if (remove) {
messages.remove(message);
message.delete();
} else {