Search code examples
apache-camelesbeip

Camel exchange inout is not maintaining the exception in exchange


I created a camel route without INOUT exchange pattern and the route looks like

direct:start > bean:myBean?method=handle

I'm sending payload using ProducerTemplate's send method

Exchange response = producerTemplate.send(endpointUri, exchange);

I set the exception on exchange in the bean's handle method, but its not retained in the response.

Is there something I'm missing.


Solution

  • I found where camel's hiding the exception. Since I marked the exchange as handled and marked for rollback, camel is setting the exception to null and moved it to properties.

    I was able to retrieve it using

    result.getProperty(Exchange.EXCEPTION_CAUGHT)