// OK .. we dont need to route .. its already happened
ref.store(targetVector);
boolean enforcelimit = false;
itr = dsts.iterator();
while (itr.hasNext()) {
DestinationUID did = (DestinationUID)itr.next();
Destination d = Destination.getDestination(did);
if (!hasflowcontrol) {
enforcelimit = true;
} else {
String k = ENFORCE_REMOTE_DEST_LIMIT_PROP+did.getLongString();
if (Globals.getConfig().getProperty(k) == null) {
enforcelimit = ENFORCE_REMOTE_DEST_LIMIT;
} else {
enforcelimit = Globals.getConfig().getBooleanProperty(k);
}
}
if (DEBUG) {
logger.log(logger.INFO, "Route remote message "+ref+ " sent from "+sender+
" to destination(s) "+did+" for consumer(s) "+targetVector+" hasflowcontrol="+
hasflowcontrol+", enforcelimit="+enforcelimit);
}
if ((Destination.CHECK_MSGS_RATE_FOR_ALL ||
!ref.getDestinationUID().isQueue()) && !ROUTE_REJECTED_REMOTE_MSG) {
Consumer cs = null;
Subscription sub = null;
Iterator csitr = targetVector.iterator();
while (csitr.hasNext()) {
cs = (Consumer)csitr.next();
sub = cs.getSubscription();
if (Destination.CHECK_MSGS_RATE_FOR_ALL ||
(CHECK_MSGRATE_ON_ARRIVAL &&
sub != null && sub.getShared() && !sub.isDurable())) {
int ret = cs.checkIfMsgsInRateGTOutRate(d);
if (ret == 0) {
ignoreVector.addAll(targetVector);
targetVector.clear();
ignoreProps = ignoreUnroutableProp;
break;
}
}
}
if (targetVector.isEmpty()) {
break;
}
}
if (!d.queueMessage(ref, false, enforcelimit)) { // add to message count
ignoreVector.addAll(targetVector);
if (!ROUTE_REJECTED_REMOTE_MSG) {
targetVector.clear();
}
break;
} else {
cleanupDests.add(d);
}
}
} else if (exists) {
ref.add(targetVector);
}
}
} catch (IOException ex) {
logger.logStack(logger.INFO,"Internal Exception ", ex);
ignoreVector.addAll(targetVector);
if (!ROUTE_REJECTED_REMOTE_MSG) {
targetVector.clear();
ignoreProps = ignoreUnroutableProp;
}
} catch (BrokerException ex) {
// unable to store
ignoreVector.addAll(targetVector);
if (!ROUTE_REJECTED_REMOTE_MSG) {
targetVector.clear();
ignoreProps = ignoreUnroutableProp;
}
}
if (targetVector.isEmpty()) {
Destination d = null;
itr = cleanupDests.iterator();
while (itr.hasNext()) {
try {
d = (Destination)itr.next();
d.removeMessage(ref.getSysMessageID(), null);
} catch (Throwable e) {
Object[] args = { ref.getSysMessageID(),
(sender == null ? "":sender),
d, targetVector.toString(), e.toString() };
String emsg = Globals.getBrokerResources().getKString(
BrokerResources.W_UNABLE_CLEANUP_REMOTE_MSG_ON_ROUTE, args);
if (DEBUG) {
logger.logStack(Logger.WARNING, emsg, e);
} else {
logger.log(Logger.WARNING, emsg);
}
}
}
cleanupDests.clear();
}
// Now deliver the message...
String debugString = "\n";
int i;
for (i = 0; i < targetVector.size(); i++) {
Consumer interest = (Consumer)targetVector.get(i);
if (!interest.routeMessage(ref, false)) {
// it disappeard on us, take care of it
try {
if (ref.acknowledged(interest.getConsumerUID(),
interest.getStoredConsumerUID(), true, false)) {
if (dsts == null) continue;
itr = dsts.iterator();
while (itr.hasNext()) {
DestinationUID did = (DestinationUID)itr.next();
Destination d=Destination.getDestination(did);
d.removeRemoteMessage(ref.getSysMessageID(),
RemoveReason.ACKNOWLEDGED, ref);
}
}