【问题标题】:camel-http4 2.22 - toD not workingcamel-http4 2.22 - toD 不工作
【发布时间】:2021-12-23 23:19:30
【问题描述】:

在迁移到 2.22.0(从 2.16.5)后,动态路由 (toD) 中的骆驼动态 uri 似乎已停止为我工作。演示该问题的测试路线:

<route>
    <from uri="timer://foo?fixedRate=true&amp;period=1000"/>
    <setHeader headerName="SMSURI">
        <constant>localhost:9090/</constant>
    </setHeader>
    <toD uri="https4://${header.SMSURI}?throwExceptionOnFailure=false"/>
</route>

我得到以下异常:

2018-08-11T14:41:07,770 | INFO  | Camel (testContext) thread #27 - timer://foo | route5                           | 160 - org.apache.camel.camel-core - 2.22.0 | java.lang.IllegalArgumentException: Cannot find endpoint with scheme https4
    at org.apache.camel.runtimecatalog.AbstractCamelCatalog.endpointProperties(AbstractCamelCatalog.java:529)
    at org.apache.camel.http.common.HttpSendDynamicAware.prepare(HttpSendDynamicAware.java:57)
    at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:118)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
    at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:197)
    at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:79)
    at java.util.TimerThread.mainLoop(Timer.java:555)
    at java.util.TimerThread.run(Timer.java:505)

我知道动态uri有两种替代方法,一种是设置Exchange.HTTP_URI,然后使用带有任意url的静态路由'to',第二种是使用reciepientList。但是,我不喜欢使用“to”的第一个选项,因为我需要设置任意 url。我目前正在使用第二个选项,receipientList 类似这样的东西(注意这里的 setHeader 仅用于演示。url 是在我的项目的处理器类中动态检索和设置的):

<route>
    <from uri="timer://foo?fixedRate=true&amp;period=1000"/>
    <setHeader headerName="SMSURI">
        <constant>localhost:9090/</constant>
    </setHeader>
    <recipientList>
        <simple>https4://${header.SMSURI}?throwExceptionOnFailure=false</simple>
    </recipientList>
</route>

这行得通。不过,我真的很喜欢 toD 选项。

另外,骆驼网站说:

Dynamic To - 开箱即用

从 Camel 2.16 开始,有一个新的动态 to。 在消息端点查看更多详细信息。

http://camel.apache.org/how-to-use-a-dynamic-uri-in-to.html

任何人都可以帮助我了解是否已删除对使用 http4 的 toD 的支持?或者这是一个错误?

PS:我在 OSGI 包内的 Karaf 4.2 容器中运行它,使用蓝图 xml。

【问题讨论】:

  • 确保您已将camel-http4 依赖升级到版本2.22.0。所有组件必须始终以与camel-core 相同的版本导入。
  • 是的,所有组件都是相同的版本。在 Karaf 中,一旦您添加了特定版本的骆驼存储库,所有组件也将安装为同一版本。这是一个没有 Camel 功能的全新 Karaf 安装,然后我安装了 2.22.0
  • 我们修复了 2.22.0 上的一个错误,该错误进入 2.22.1,与 toD 中的问题有关。您可以使用 recipientList 作为解决方法。
  • 谢谢克劳斯!欣赏它。目前使用收件人列表。 2.22.1 出来的时候。
  • 嗨 praveenp,我们也有同样的问题。没有 ToD 你是怎么解决的?

标签: java apache-camel


【解决方案1】:

我通过将组件放在我在 toD 中使用的标题中解决了这个问题。 示例:

<route>
    <from uri="timer://foo?fixedRate=true&amp;period=1000"/>
    <setHeader headerName="SMSURI">
        <constant>https4://localhost:9090/</constant>
    </setHeader>
    <toD uri="${headers.SMSURI}" />
</route>

【讨论】:

    猜你喜欢
    • 2018-10-03
    • 2014-10-31
    • 2017-09-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多