Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

Apache Camel REST DSL deadLetterChannel

Is it possible to use the deadLetterChannel with REST DSL? I can't figure out how to have it use the deadLetterChannel if there is an exception thrown when calling another rest endpoint.

I have something along the lines of the below, but if there is an exception thrown at the to("https4://endpoint-uri"), I would like to be able to have it go to the deadLetterChannel so I can write the data being processed to a database.

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")

I tried using onException, but the mustache component replaces the body containing the data with the template.

Thanks.

question from:https://stackoverflow.com/questions/66054445/apache-camel-rest-dsl-deadletterchannel

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Saving the original message as a property of the exchange worked. Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...