ConsumerUID storedID =(ConsumerUID) sToCmap.get(intid);
SortedSet ss = (SortedSet)entry.getValue();
Iterator itr = ss.iterator();
while (itr.hasNext()) {
PacketReference ref = (PacketReference)itr.next();
SysMessageID sysid = ref.getSysMessageID();
if (!ref.isLocal()) {
if (tid != null && translist != null) {
translist.removeOrphanAck(tid, sysid, storedID, intid);
}
try {
if (ref.acknowledged(intid, storedID,
!(intid.isNoAck()||intid.isDupsOK()),
false, tid, null, false)) {
Destination d = ref.getDestination();
d.removeRemoteMessage(sysid, RemoveReason.ACKNOWLEDGED, ref);
}
} catch(Exception ex) {
logger.logStack((DEBUG_CLUSTER_TXN ? Logger.WARNING:Logger.DEBUG),
"Unable to cleanup remote message "+
"[" + intid + "," + storedID + "," + sysid+"]"+
" on rollback transaction " +tid+" for inactive consumer.", ex);
}
BrokerAddress addr = null;
if (tid != null && translist != null) {
addr = translist.getAckBrokerAddress(tid, sysid, intid);
} else {
addr = ref.getAddress();
}
try {
HashMap prop = new HashMap();
if (tid != null) {
prop.put(ClusterBroadcast.RB_RELEASE_MSG_INACTIVE, tid.toString());
} else {
prop.put(ClusterBroadcast.RC_RELEASE_MSG_INACTIVE, "");
}
Globals.getClusterBroadcast().acknowledgeMessage(
addr, sysid, intid,
ClusterBroadcast.MSG_IGNORED,
prop, false /*no wait ack*/);
} catch (BrokerException e) {
Globals.getLogger().log(Logger.WARNING,
"Unable to notify "+addr+" for remote message "+
"["+intid+", "+storedID+", "+", "+sysid+"]"+
" in "+(tid != null ? ("rollback transaction "+ tid):("recover"))+" for inactive consumer.");
}
itr.remove();
continue;
}
}
if (storedID == null || intid == storedID) {
// non-durable subscriber
// ignore
sitr.remove();
continue;
}
if (ss.isEmpty()) {
if (DEBUG) {
logger.log(Logger.INFO, "redeliverUnackedNoConsuemr: "+
"empty local message set for consumer "+intid+"[storedID="+storedID+"]");
}
continue;
}
// see if we are a queue
if (storedID == PacketReference.getQueueUID()) {
// queue message on
// queues are complex ->
PacketReference ref = (PacketReference)ss.first();
if (ref == null) {
if (DEBUG) {
logger.log(Logger.INFO,"Internal Error: "
+ " null reterence");
}
continue;
}
try {
if (redeliver) {
ref.consumed(storedID, false, false);
} else {
ref.removeDelivered(storedID, false);
}
} catch (IOException ex) {
logger.log(Logger.WARNING,"Internal error",
ex);
}
Destination d= ref.getDestination();
if (d == null) {
if (DEBUG) {
logger.log(Logger.INFO,"Internal Error: "
+ " unknown destination for reference: "
+ ref);