camunda-community-hub / camunda-platform-7-camel

Community Extension to add Apache Camel support for Camunda Platform 7
Apache License 2.0
82 stars 57 forks source link

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

Open kiranpatel11 opened 8 years ago

kiranpatel11 commented 8 years ago

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().