CamelContext:当数据库无法访问时,创建路由包含石英失败

时间:2016-10-14 16:31:30

标签: apache-camel quartz-scheduler apache-karaf postgresql-9.4

我的软件包安装在karaf容器4.0.7中,使用camel-quartz22.17.3 在camelContext中我有很多路由,例如“myRoute”,它调用postgresql数据库中配置的作业quatrz(使用camel-quartz2):

<camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/blueprint">

        <route id="myRoute">
            <from
                uri="quartz2://statGroup/startupTimer?trigger.repeatInterval=1&amp;trigger.repeatCount=0" />
            <bean ref="myProcessor" method="myMethod" />
        </route>

 </camelContext>

我的问题是当我尝试启动karaf容器并且postgresql停止时,我有下面的日志问题,并且camelContext“myCamelContext”将被关闭。

可以创建调用camel-quartz的路由,但数据库无法访问?

2016-10-14 17:21:40,201 | ERROR | FelixStartLevel  | BlueprintCamelContext            | 80 - org.apache.camel.camel-blueprint - 2.17.3 | Error occurred during starting Camel: CamelContext(statisticsContext) due Failed to create route myRoute: Route(myRoute)[[From[quartz2://stat... because of Failed to resolve endpoint: quartz2://statGroup/startupTimer?trigger.repeatCount=0&trigger.repeatInterval=1 due to: Failed to obtain DB connection from data source 'statQuartzDS': java.sql.SQLException: Could not retrieve datasource via JNDI url 'osgi:service/statQuartzDS' java.sql.SQLException: Unable to acquire a new connection from the pool
org.apache.camel.FailedToCreateRouteException: Failed to create route myRoute: Route(myRoute)[[From[quartz2://stat... because of Failed to resolve endpoint: quartz2://statGroup/startupTimer?trigger.repeatCount=0&trigger.repeatInterval=1 due to: Failed to obtain DB connection from data source 'statQuartzDS': java.sql.SQLException: Could not retrieve datasource via JNDI url 'osgi:service/statQuartzDS' java.sql.SQLException: Unable to acquire a new connection from the pool
    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:201)
    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:974)[83:org.apache.camel.camel-core:2.17.3]
    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3301)[83:org.apache.camel.camel-core:2.17.3]
    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3024)[83:org.apache.camel.camel-core:2.17.3]
    at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:175)[83:org.apache.camel.camel-core:2.17.3]
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2854)
    at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2850)
    at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2873)[83:org.apache.camel.camel-core:2.17.3]
    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2850)[83:org.apache.camel.camel-core:2.17.3]
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2819)[83:org.apache.camel.camel-core:2.17.3]
    at org.apache.camel.blueprint.BlueprintCamelContext.start(BlueprintCamelContext.java:180)
    at org.apache.camel.blueprint.BlueprintCamelContext.maybeStart(BlueprintCamelContext.java:212)
    at org.apache.camel.blueprint.BlueprintCamelContext.serviceChanged(BlueprintCamelContext.java:150)
    at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:991)[org.apache.felix.framework-5.4.0.jar:]
    at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:839)[org.apache.felix.framework-5.4.0.jar:]
    at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:546)[org.apache.felix.framework-5.4.0.jar:]
    at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4557)[org.apache.felix.framework-5.4.0.jar:]
    at org.apache.felix.framework.Felix.registerService(Felix.java:3549)[org.apache.felix.framework-5.4.0.jar:]
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:348)
    at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:355)
    at org.apache.camel.blueprint.BlueprintCamelContext.init(BlueprintCamelContext.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_101]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_101]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_101]
    at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_101]
    at org.apache.aries.blueprint.utils.ReflectionUtils.invoke(ReflectionUtils.java:299)[12:org.apache.aries.blueprint.core:1.6.2]
    at org.apache.aries.blueprint.container.BeanRecipe.invoke(BeanRecipe.java:980)[12:org.apache.aries.blueprint.core:1.6.2]
    at org.apache.aries.blueprint.container.BeanRecipe.runBeanProcInit(BeanRecipe.java:736)[12:org.apache.aries.blueprint.core:1.6.2]
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:848)[12:org.apache.aries.blueprint.core:1.6.2]
    at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)[12:org.apache.aries.blueprint.core:1.6.2]
    at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[12:org.apache.aries.blueprint.core:1.6.2]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_101]

0 个答案:

没有答案