use of com.swiftmq.swiftlet.routing.event.RoutingEvent in project swiftmq-ce by iitsoftware.
the class DefaultScheduler method getNextConnection.
protected synchronized RoutingConnection getNextConnection() {
RoutingConnection rc = null;
if (connections.size() == 0) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 0, rc=" + rc);
return null;
}
if (connections.size() == 1) {
rc = ((ConnectionEntry) connections.get(0)).getRoutingConnection();
if (rc.isClosed()) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 1, rc is closed");
connections.clear();
rc = null;
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 1, rc=" + rc);
} else {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == " + connections.size() + " ...");
for (Iterator iter = connections.iterator(); iter.hasNext(); ) {
rc = ((ConnectionEntry) iter.next()).getRoutingConnection();
if (rc.isClosed()) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == " + connections.size() + ", rc is closed");
iter.remove();
rc = null;
} else
break;
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == " + connections.size() + ", rc=" + rc);
}
if (rc == null && connections.size() == 0) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, connections.size() == 0, rc=" + rc + ", destinationDeactivated");
ctx.routingSwiftlet.fireRoutingEvent("destinationDeactivated", new RoutingEvent(ctx.routingSwiftlet, destinationRouter));
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getNextConnection, rc=" + rc);
return rc;
}
Aggregations