【问题标题】:Apache Camel REST DSL deadLetterChannelApache Camel REST DSL deadLetterChannel
【发布时间】:2021-02-04 21:57:14
【问题描述】:

是否可以将 deadLetterChannel 与 REST DSL 一起使用?如果在调用另一个休息端点时抛出异常,我不知道如何让它使用 deadLetterChannel。

我有一些类似下面的内容,但是如果to("https4://endpoint-uri") 出现异常,我希望能够将其发送到 deadLetterChannel,以便将正在处理的数据写入数据库.

rest().description("Add meter reading.")
    .post("/meter-reading")
    .consumes(MediaType.APPLICATION_JSON_VALUE)
    .produces(MediaType.APPLICATION_JSON_VALUE)
    .route().routeId("addMeterReading")
    .process(mileageProcessor)
    .to("mustache:mustache/add-meter-reading.mustache")
    .to("https4://endpoint-uri")

我尝试使用onException,但是 mustache 组件用模板替换了包含数据的正文。

谢谢。

【问题讨论】:

  • 将原始消息保存为交换的属性。在异常情况下,您可以检索它。
  • 如果可行,请在此处添加它作为答案。会赞成它。

标签: rest apache-camel dsl


【解决方案1】:

将原始消息保存为交换的属性有效。谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多