Commit 76758c1f authored by Andre Freyssinet's avatar Andre Freyssinet

Enhancemments during messages loading at startup (Joram-358).

parent 6675b737
......@@ -599,11 +599,12 @@ public class Queue extends Destination implements QueueMBean {
messages = new Vector<Message>(persistedMsgs.size());
if (persistedMsgs != null) {
Message persistedMsg;
QueueDelivery queueDelivery;
while (! persistedMsgs.isEmpty()) {
persistedMsg = (Message) persistedMsgs.remove(0);
// TODO (AF): Add the message to the end of the messages list.
// Browse the persistedMsgs list in order without deleting items.
for (Message persistedMsg : persistedMsgs) {
queueDelivery = deliveryTable.get(persistedMsg.getId());
if (logmsg.isLoggable(BasicLevel.INFO))
......@@ -614,6 +615,8 @@ public class Queue extends Destination implements QueueMBean {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, getName() + ": schedule " + persistedMsg.getId());
delayedMessageCount += 1;
// TODO (AF): Be careful, this way of handling timed messages is not scalable. We should maintain an
// ordered list of timed messages, and set a timer for the first timeout (see Scheduler class).
AgentServer.getTimer().schedule(new QueueDeliveryTimeTask(getId(), persistedMsg, false), new Date(persistedMsg.getDeliveryTime()));
} else {
if (logger.isLoggable(BasicLevel.DEBUG))
......@@ -1643,6 +1646,7 @@ public class Queue extends Destination implements QueueMBean {
} else {
// Denying or recovery: adding the message according to its original arrival order.
int i = 0;
// TODO (AF): May be it is not the best way to browse the message list.
for (Iterator ite = messages.iterator(); ite.hasNext();) {
if (((Message) ite.next()).order > message.order) break;
i++;
......
......@@ -548,35 +548,37 @@ public final class Message implements Comparable<Message>, Serializable, Encodab
int nb = 0;
Message msg;
start = System.currentTimeMillis();
for (int i = 0; i < names.length; i++) {
if (names[i].charAt(names[i].length() - 1) == 'B')
for (String name : names) {
if (name.charAt(name.length() - 1) == 'B')
continue;
try {
if (nb < max) {
msg = (Message) tx.load(names[i]);
msg = (Message) tx.load(name);
// Test the order get from txname
int idx = names[i].lastIndexOf('_');
long order = Long.parseLong(names[i].substring(idx+1));
if (order != msg.order)
logger.log(BasicLevel.WARN,
"Message.loadAll: Message " + names[i] + " -> " + msg.order + " != " + order);
int idx = name.lastIndexOf('_');
if (logger.isLoggable(BasicLevel.DEBUG)) {
long order = Long.parseLong(name.substring(idx+1));
if (order != msg.order)
logger.log(BasicLevel.WARN,
"Message.loadAll: Message " + name + " -> " + msg.order + " != " + order);
}
} else {
msg = new Message();
// Get order from txname
int idx = names[i].lastIndexOf('_');
msg.order = Long.parseLong(names[i].substring(idx+1));
int idx = name.lastIndexOf('_');
msg.order = Long.parseLong(name.substring(idx+1));
}
msg.txname = names[i];
msg.txname = name;
nb += 1;
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Message.loadAll: names[" + i + "] = " + msg.txname);
"Message.loadAll: names[" + nb + "] = " + msg.txname);
messages.add(msg);
} catch (Exception exc) {
logger.log(BasicLevel.ERROR,
"Message.loadAll: Message named [" + names[i] + "] can not be loaded", exc);
"Message.loadAll: Message named [" + name + "] can not be loaded", exc);
}
}
end = System.currentTimeMillis();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment