我有一个骆驼应用程序,其计时器路由定义如下:
String timerURI = "timer:/MyApplication?period=5m";
我意识到URI语法可能不正确。 Apache Camel网站上显示的正确语法应为:
String timerURI = timer://MyApplication?period=5m";
但是,我注意到日志中有一些奇怪的行为。 在第一个实例中,我显示了骆驼将URI记录为:
(route1) from(timer:///MyApplication?period=5m) --> bean[com.mypackage.....]
在第二种情况下,日志显示为:
(route1) from(timer://MyApplication?period=5m) --> bean[com.mypackage.....]
我尝试了第三种选择
String timerURI = timer:MyApplication?period=5m";
它在日志中显示为:
(route1) from(timer://MyApplication?period=5m) --> bean[com.mypackage.....]
当我用单个/定义URI时,如在第一种情况下,我看到这样的异常:
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: direct: due to: Expected scheme-specific part at index 7: direct:
at org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:601)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:483)
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:63)
at org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:88)
at org.apache.camel.processor.RecipientListProcessor.resolveEndpoint(RecipientListProcessor.java:223)
at org.apache.camel.processor.RecipientListProcessor.createProcessorExchangePairs(RecipientListProcessor.java:163)
at org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:208)
at org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:153)
at org.apache.camel.processor.RecipientList.process(RecipientList.java:112
::::::::::::::::::::::::::::::::
Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 7: direct:
at java.net.URI$Parser.fail(URI.java:2829)
at java.net.URI$Parser.failExpecting(URI.java:2835)
at java.net.URI$Parser.parse(URI.java:3038)
at java.net.URI.(URI.java:595)
at org.apache.camel.util.URISupport.normalizeUri(URISupport.java:448)
at org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:599)
... 51 more
因此,只有在第一个实例中只有一个/时,我才看到此异常,但其他两个似乎都很好。 即使是陌生人,错误也不会经常重复。 我从未在本地工作区中看到它,但在Dev测试服务器中看到了两次,而在Integration测试服务器中看到了一次。 即使此异常失败,它也会在计时器5分钟后运行时在下次运行。 有谁知道骆驼如何解释这些URL,为什么它几次失败了?