Apache Camel REST DSL deadLetterChannel

Viewed 40

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.

1 Answers

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

Related