if (nodeId.equalsIgnoreCase(nh.getId().toStringFull())) {
log
.debug("Found a node in leaf set to which the message can be "
+ "sent directly: " + nodeId);
found = true;
final Counter counter = new Counter(1);
endpoint.route(null, message, nh, new DeliveryNotification() {
public void sendFailed(MessageReceipt arg0, Exception arg1) {
log.warn("Failed to directly send a message", arg1);
counter.decrement();
}
public void sent(MessageReceipt arg0) {
counter.decrement();
}
});
while (counter.getValue() == 1) {
}
break;
}
}