@Override public void pause() { checkStarted(); clearIO(); try { queue.pause(); } finally { blockOnIO(); } }
@Override public void handleAddMessage(Map<Long, Map<Long, AddMessageRecord>> queueMap) throws Exception { for (Map.Entry<Long, Map<Long, AddMessageRecord>> entry : queueMap.entrySet()) { long queueID = entry.getKey(); Map<Long, AddMessageRecord> queueRecords = entry.getValue(); Queue queue = this.queues.get(queueID); if (queue == null) { if (queueRecords.values().size() != 0) { ActiveMQServerLogger.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.getScheduledDeliveryTime(); if (scheduledDeliveryTime != 0 && scheduledDeliveryTime <= currentTime) { scheduledDeliveryTime = 0; record.getMessage().removeProperty(Message.HDR_SCHEDULED_DELIVERY_TIME); } if (scheduledDeliveryTime != 0) { record .getMessage() .putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, scheduledDeliveryTime); } MessageReference ref = postOffice.reroute(record.getMessage(), queue, null); ref.setDeliveryCount(record.getDeliveryCount()); if (scheduledDeliveryTime != 0) { record.getMessage().removeProperty(Message.HDR_SCHEDULED_DELIVERY_TIME); } } } }