Search in sources :

Example 1 with RouteImpl

use of com.swiftmq.impl.routing.single.RouteImpl in project swiftmq-ce by iitsoftware.

the class SchedulerRegistry method getScheduler.

public synchronized Scheduler getScheduler(String destinationRouter) throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getScheduler, destinationRouter=" + destinationRouter);
    Scheduler scheduler = (Scheduler) schedulers.get(destinationRouter);
    if (scheduler == null) {
        if (ctx.traceSpace.enabled)
            ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getScheduler, destinationRouter=" + destinationRouter + ", creating scheduler...");
        String queueName = QUEUE_PREFIX + destinationRouter + "@" + ctx.routerName;
        if (!ctx.queueManager.isQueueDefined(queueName))
            ctx.queueManager.createQueue(queueName, (ActiveLogin) null);
        ctx.queueManager.setQueueOutboundRedirector(OUTBOUND_REDIR_PRED + destinationRouter, queueName);
        if (ctx.roundRobinEnabled) {
            scheduler = new RoundRobinScheduler(ctx, destinationRouter, queueName);
        } else {
            scheduler = new DefaultScheduler(ctx, destinationRouter, queueName);
        }
        schedulers.put(destinationRouter, scheduler);
        RouteImpl route = (RouteImpl) ctx.routingSwiftlet.getRoute(destinationRouter);
        if (route == null)
            ctx.routingSwiftlet.addRoute(new RouteImpl(destinationRouter, queueName, true, scheduler));
        else
            route.setScheduler(scheduler);
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/getScheduler, destinationRouter=" + destinationRouter + ", returns " + scheduler);
    return scheduler;
}
Also used : ActiveLogin(com.swiftmq.swiftlet.auth.ActiveLogin) RouteImpl(com.swiftmq.impl.routing.single.RouteImpl)

Example 2 with RouteImpl

use of com.swiftmq.impl.routing.single.RouteImpl in project swiftmq-ce by iitsoftware.

the class SchedulerRegistry method removeScheduler.

public synchronized void removeScheduler(String destinationRouter) throws Exception {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), toString() + "/removeScheduler, destinationRouter=" + destinationRouter);
    Scheduler scheduler = (Scheduler) schedulers.remove(destinationRouter);
    if (scheduler != null) {
        scheduler.close();
        RouteImpl route = (RouteImpl) ctx.routingSwiftlet.getRoute(destinationRouter);
        if (route != null) {
            if (route.isStaticRoute())
                route.setScheduler(null);
            else {
                ctx.queueManager.setQueueOutboundRedirector(OUTBOUND_REDIR_PRED + destinationRouter, null);
                ctx.routingSwiftlet.removeRoute(route);
            }
        }
    }
}
Also used : RouteImpl(com.swiftmq.impl.routing.single.RouteImpl)

Aggregations

RouteImpl (com.swiftmq.impl.routing.single.RouteImpl)2 ActiveLogin (com.swiftmq.swiftlet.auth.ActiveLogin)1