Apache camel Apache骆驼计时器路由URI语法

Apache camel Apache骆驼计时器路由URI语法,apache-camel,Apache Camel,我有一个camel应用程序,其计时器路由定义如下: String timerURI = "timer:/MyApplication?period=5m"; org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: direct: due to: Expected scheme-specific part at index 7: direct: at org.apache.camel.impl

我有一个camel应用程序,其计时器路由定义如下:

String timerURI = "timer:/MyApplication?period=5m";
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.<init>(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
我意识到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时,我看到如下异常:

String timerURI = "timer:/MyApplication?period=5m";
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.<init>(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
org.apache.camel.ResolveEndpointFailedException:未能解析端点:直接:原因:索引7处的预期方案特定部分:直接:
位于org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:601)
位于org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:483)
位于org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:63)
位于org.apache.camel.util.ExchangeHelper.resolveEndpoint(ExchangeHelper.java:88)
位于org.apache.camel.processor.RecipientListProcessor.resolveEndpoint(RecipientListProcessor.java:223)
位于org.apache.camel.processor.RecipientListProcessor.createProcessorExchangePairs(RecipientListProcessor.java:163)
位于org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:208)
位于org.apache.camel.processor.RecipientList.sendToRecipientList(RecipientList.java:153)
位于org.apache.camel.processor.RecipientList.process(RecipientList.java:112
::::::::::::::::::::::::::::::::
原因:java.net.URISyntaxException:索引7处的预期方案特定部分:直接:
位于java.net.URI$Parser.fail(URI.java:2829)
位于java.net.URI$Parser.failExpecting(URI.java:2835)
位于java.net.URI$Parser.parse(URI.java:3038)
位于java.net.URI。(URI.java:595)
位于org.apache.camel.util.URISupport.normalizeUri(URISupport.java:448)
位于org.apache.camel.impl.DefaultCamelContext.normalizeEndpointUri(DefaultCamelContext.java:599)
…还有51个

因此,只有在第一个实例中,当我使用single/时,我才看到了这个异常,但其他两个似乎没有问题。尽管如此,这个错误并不经常重复。我从来没有在本地工作区看到过它,但我在我的开发测试服务器中看到过两次,在集成测试服务器中看到过一次。即使在出现此异常失败后,它在下一个t计时器在5分钟后运行时输入ime。有人知道camel是如何解释这些URL的,以及为什么它会失败几次吗?

使用无斜杠或双斜杠。例如

"timer:foo"

当使用双斜杠时,Camel认为这是没有斜杠的,例如,可以在浏览器中键入http:foo.com


如果使用1或3个斜杠,则该斜杠将成为组件上下文路径的一部分。只有少数组件支持前导斜杠,例如前导斜杠表示起始目录为
/foo
等的文件/ftp组件。

不使用斜杠,或使用双斜杠。例如

"timer:foo"

当使用双斜杠时,Camel认为这是没有斜杠的,例如,可以在浏览器中键入http:foo.com


如果使用1或3个斜杠,则该斜杠将成为组件上下文路径的一部分。只有少数组件支持前导斜杠,例如前导斜杠表示起始目录为
/foo
等的文件/ftp组件。

不使用斜杠,或使用双斜杠。例如

"timer:foo"

当使用双斜杠时,Camel认为这是没有斜杠的,例如,可以在浏览器中键入http:foo.com


如果使用1或3个斜杠,则该斜杠将成为组件上下文路径的一部分。只有少数组件支持前导斜杠,例如前导斜杠表示起始目录为
/foo
等的文件/ftp组件。

不使用斜杠,或使用双斜杠。例如

"timer:foo"

当使用双斜杠时,Camel认为这是没有斜杠的,例如,可以在浏览器中键入http:foo.com


如果使用1或3个斜杠,则该斜杠将成为组件上下文路径的一部分。只有少数组件支持前导斜杠,例如前导斜杠表示起始目录的文件/ftp组件是
/foo
等。

是否有任何解释说明为什么除少数几次外,1个斜杠基本上都有效?我会体验一下如果无效,ted会一直出错。是否有任何解释说明为什么1个斜杠除了少数几次外大部分都有效?如果无效,我会一直预期错误。是否有任何解释说明为什么1个斜杠除了少数几次外大部分都有效?如果无效,我会一直预期错误。是否有任何解释说明为什么1个斜杠有效除了少数几次之外,大多数情况下都会出错?如果它无效,我会一直预料到错误。Rishi-你能提供示例代码吗?我正在努力在代码中使用from()API,不确定如何在spring application-context.xml中配置camel quartz?@javaHelper:Router Class:
String timerURI=timer://MyApplication?period=5m“;@Autowired私有MyApplicationConsumerClass使用者;from(timerUrl).bean(使用者,“processQueueOnTimer('queueTimer')”);
使用者类:
@Component公共类MyApplicationConsumerClass{public void processQueueOnTimer(字符串queueTimer,Exchange)引发异常{…}”
Rishi-您能提供示例代码吗?我正在努力在代码中使用from()API,不确定如何在spring application-context.xml中配置camel quartz?@javaHelper:Router Class:
String timerURI=timer://MyApplication?period=5m“;@Autowired私有MyApplicationConsumerClass使用者;来自(timerUrl).bean(使用者,“processQueueOnTimer('queueTimer')”;
使用者类:
@组件公共类MyApplicationConsumerClass{public void processQueueOnTimer(字符串queueTimer,Ex