【发布时间】: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