camunda-platform-7-camel icon indicating copy to clipboard operation
camunda-platform-7-camel copied to clipboard

Sync outbound call using ${camel.sendTo(...)} does not throw exception

Open kiranpatel11 opened this issue 8 years ago • 0 comments

The camunda-bpm-camel component's camel.sendTo is internally calling producerTemplate.send()

The send() method is not designed to throw the exception to the caller (camunda-bpm-camel component in this case). This makes it impossible to handle the thrown exception in BPM process. e.g. In case of business errors, I would like to throw BpmnError and create UserTask, In cases of technical error, just rethrow the exception so that the execution gets faulted and retried as per the configuration.

Even if I map different exceptions in my route, the camel always makes it available either as Exchange.getException() if i call send() method or CamelExecutionException if I call sendBody() on producerTemplate.

javadoc of the producerTemplate.send(String endpointUri, Exchange exchange) Sends the exchange to the given endpoint Notice: that if the processing of the exchange failed with an Exception it is not thrown from this method, but you can access it from the returned exchange using Exchange.getException().

I think the component needs to change to check the Exchange.getException() and rethow it after calling template.send().

kiranpatel11 avatar Sep 22 '16 20:09 kiranpatel11