當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceStatus.Suspended方法代碼示例

本文整理匯總了Java中org.apache.camel.ServiceStatus.Suspended方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceStatus.Suspended方法的具體用法?Java ServiceStatus.Suspended怎麽用?Java ServiceStatus.Suspended使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.camel.ServiceStatus的用法示例。


在下文中一共展示了ServiceStatus.Suspended方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getStatus

import org.apache.camel.ServiceStatus; //導入方法依賴的package包/類
@Override
public ServiceStatus getStatus() {
    // we should check the ---ing states first, as this indicate the state is in the middle of doing that
    if (isStarting()) {
        return ServiceStatus.Starting;
    }
    if (isStopping()) {
        return ServiceStatus.Stopping;
    }
    if (isSuspending()) {
        return ServiceStatus.Suspending;
    }

    // then check for the regular states
    if (isStarted()) {
        return ServiceStatus.Started;
    }
    if (isStopped()) {
        return ServiceStatus.Stopped;
    }
    if (isSuspended()) {
        return ServiceStatus.Suspended;
    }

    // use stopped as fallback
    return ServiceStatus.Stopped;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:28,代碼來源:ServiceSupport.java

示例2: onJobExecute

import org.apache.camel.ServiceStatus; //導入方法依賴的package包/類
protected void onJobExecute(Action action, Route route) throws Exception {
    LOG.debug("Scheduled Event notification received. Performing action: {} on route: {}", action, route.getId());

    ServiceStatus routeStatus = route.getRouteContext().getCamelContext().getRouteStatus(route.getId());
    if (action == Action.START) {
        if (routeStatus == ServiceStatus.Stopped) {
            startRoute(route);
            // here we just check the states of the Consumer
        } else if (ServiceHelper.isSuspended(route.getConsumer())) {
            startConsumer(route.getConsumer());
        }
    } else if (action == Action.STOP) {
        if ((routeStatus == ServiceStatus.Started) || (routeStatus == ServiceStatus.Suspended)) {
            stopRoute(route, getRouteStopGracePeriod(), getTimeUnit());
        } else {
            LOG.warn("Route is not in a started/suspended state and cannot be stopped. The current route state is {}", routeStatus);
        }
    } else if (action == Action.SUSPEND) {
        if (routeStatus == ServiceStatus.Started) {
            stopConsumer(route.getConsumer());
        } else {
            LOG.warn("Route is not in a started state and cannot be suspended. The current route state is {}", routeStatus);
        }
    } else if (action == Action.RESUME) {
        if (routeStatus == ServiceStatus.Started) {
            if (ServiceHelper.isSuspended(route.getConsumer())) {
                startConsumer(route.getConsumer());
            } else {
                LOG.warn("The Consumer {} is not suspended and cannot be resumed.", route.getConsumer());
            }
        } else {
            LOG.warn("Route is not in a started state and cannot be resumed. The current route state is {}", routeStatus);
        }
    }       
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:36,代碼來源:ScheduledRoutePolicy.java


注:本文中的org.apache.camel.ServiceStatus.Suspended方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。