CursorAckRecordEncoding encoding = new CursorAckRecordEncoding();
encoding.decode(buff);
encoding.position.setRecordID(record.id);
PageSubscription sub = locateSubscription(encoding.queueID, pageSubscriptions, queueInfos, pagingManager);
if (sub != null)
{
sub.reloadACK(encoding.position);
}
else
{
log.info("Can't find queue " + encoding.queueID + " while reloading ACKNOWLEDGE_CURSOR, deleting record now");
messageJournal.appendDeleteRecord(record.id, false);
}
break;
}
case PAGE_CURSOR_COUNTER_VALUE:
{
PageCountRecord encoding = new PageCountRecord();
encoding.decode(buff);
PageSubscription sub = locateSubscription(encoding.queueID, pageSubscriptions, queueInfos, pagingManager);
if (sub != null)
{
sub.getCounter().loadValue(record.id, encoding.value);
}
else
{
log.info("Can't find queue " + encoding.queueID + " while reloading PAGE_CURSOR_COUNTER_VALUE, deleting record now");
messageJournal.appendDeleteRecord(record.id, false);
}
break;
}
case PAGE_CURSOR_COUNTER_INC:
{
PageCountRecordInc encoding = new PageCountRecordInc();
encoding.decode(buff);
PageSubscription sub = locateSubscription(encoding.queueID, pageSubscriptions, queueInfos, pagingManager);
if (sub != null)
{
sub.getCounter().loadInc(record.id, encoding.value);
}
else
{
log.info("Can't find queue " + encoding.queueID + " while reloading PAGE_CURSOR_COUNTER_INC, deleting record now");
messageJournal.appendDeleteRecord(record.id, false);
}
break;
}
default:
{
throw new IllegalStateException("Invalid record type " + recordType);
}
}
// This will free up memory sooner. The record is not needed any more
// and its byte array would consume memory during the load process even though it's not necessary any longer
// what would delay processing time during load
records.set(reccount, null);
}
// Release the memory as soon as not needed any longer
records.clear();
records = null;
for (Map.Entry<Long, Map<Long, AddMessageRecord>> entry : queueMap.entrySet())
{
long queueID = entry.getKey();
Map<Long, AddMessageRecord> queueRecords = entry.getValue();
Queue queue = queues.get(queueID);
if (queue == null)
{
log.warn("Message for queue " + queueID + " which does not exist. This message will be ignored.");
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)