{
long queueID = entry.getKey();
Map<Long, AddMessageRecord> queueRecords = entry.getValue();
Queue queue = queues.get(queueID);
if (queue == null)
{
if (queueRecords.values().size() != 0)
{
HornetQServerLogger.LOGGER.journalCannotFindQueueForMessage(queueID);
}
continue;
}
// Redistribution could install a Redistributor while we are still loading records, what will be an issue with
// prepared ACKs
// We make sure te Queue is paused before we reroute values.
queue.pause();
Collection<AddMessageRecord> valueRecords = queueRecords.values();
long currentTime = System.currentTimeMillis();
for (AddMessageRecord record : valueRecords)
{
long scheduledDeliveryTime = record.scheduledDeliveryTime;
if (scheduledDeliveryTime != 0 && scheduledDeliveryTime <= currentTime)
{
scheduledDeliveryTime = 0;
record.message.removeProperty(Message.HDR_SCHEDULED_DELIVERY_TIME);
}
if (scheduledDeliveryTime != 0)
{
record.message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, scheduledDeliveryTime);
}
MessageReference ref = postOffice.reroute(record.message, queue, null);
ref.setDeliveryCount(record.deliveryCount);
if (scheduledDeliveryTime != 0)
{
record.message.removeProperty(Message.HDR_SCHEDULED_DELIVERY_TIME);
}
}
}
loadPreparedTransactions(postOffice,
pagingManager,
resourceManager,
queues,
queueInfos,
preparedTransactions,
duplicateIDMap,
pageSubscriptions,
pendingLargeMessages);
for (PageSubscription sub : pageSubscriptions.values())
{
sub.getCounter().processReload();
}
for (LargeServerMessage msg : largeMessages)
{
if (msg.getRefCount() == 0)
{
HornetQServerLogger.LOGGER.largeMessageWithNoRef(msg.getMessageID());
msg.decrementDelayDeletionCount();
}
}
for (ServerMessage msg : messages.values())
{
if (msg.getRefCount() == 0)
{
HornetQServerLogger.LOGGER.journalUnreferencedMessage(msg.getMessageID());
try
{
deleteMessage(msg.getMessageID());
}
catch (Exception ignored)
{
HornetQServerLogger.LOGGER.journalErrorDeletingMessage(ignored, msg.getMessageID());
}
}
}
// To recover positions on Iterators
if (pagingManager != null)
{
// it could be null on certain tests that are not dealing with paging
// This could also be the case in certain embedded conditions
pagingManager.processReload();
}
if (perfBlastPages != -1)
{
messageJournal.perfBlast(perfBlastPages);
}
for (Queue queue : queues.values())
{
queue.resume();
}
if (System.getProperty("org.hornetq.opt.directblast") != null)
{
messageJournal.runDirectJournalBlast();