//Sort into different list for each channel
Map ackMap = new HashMap();
for (Iterator iter = deliveryRecoveryInfos.iterator(); iter.hasNext(); )
{
DeliveryRecovery deliveryInfo = (DeliveryRecovery)iter.next();
String queueName = deliveryInfo.getQueueName();
List acks = (List)ackMap.get(queueName);
if (acks == null)
{
acks = new ArrayList();
ackMap.put(queueName, acks);
}
acks.add(deliveryInfo);
}
Iterator iter = ackMap.entrySet().iterator();
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry)iter.next();
String queueName = (String)entry.getKey();
//Look up the queue
Binding binding = postOffice.getBindingForQueueName(queueName);
Queue queue = binding.queue;
if (queue == null)
{
throw new IllegalStateException("Cannot find queue with queue name: " + queueName);
}
List acks = (List)entry.getValue();
List ids = new ArrayList(acks.size());
for (Iterator iter2 = acks.iterator(); iter2.hasNext(); )
{
DeliveryRecovery info = (DeliveryRecovery)iter2.next();
ids.add(new Long(info.getMessageID()));
}
JMSCondition cond = (JMSCondition)binding.condition;
ManagedDestination dest =
sp.getDestinationManager().getDestination(cond.getName(), cond.isQueue());
if (dest == null)
{
throw new IllegalStateException("Cannot find managed destination with name " +
cond.getName() + " isQueue" + cond.isQueue());
}
Queue dlqToUse =
dest.getDLQ() == null ? defaultDLQ : dest.getDLQ();
Queue expiryQueueToUse =
dest.getExpiryQueue() == null ? defaultExpiryQueue : dest.getExpiryQueue();
int maxDeliveryAttemptsToUse =
dest.getMaxDeliveryAttempts() == -1 ? defaultMaxDeliveryAttempts : dest.getMaxDeliveryAttempts();
List dels = queue.recoverDeliveries(ids);
Iterator iter2 = dels.iterator();
Iterator iter3 = acks.iterator();
while (iter2.hasNext())
{
Delivery del = (Delivery)iter2.next();
DeliveryRecovery info = (DeliveryRecovery)iter3.next();
long deliveryId = info.getDeliveryID();
maxDeliveryId = Math.max(maxDeliveryId, deliveryId);
if (trace) { log.trace(this + " Recovered delivery " + deliveryId + ", " + del); }