camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hervé BARRAULT <herve.barra...@gmail.com>
Subject ProducerTemplate and Exception Management
Date Fri, 17 Aug 2012 16:20:03 GMT
Hi,
I used a producer template to send a body.

I have found a method which is

void *sendBody*(String
<http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true>
endpointUri,
              Object
<http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true>
body)
              throws CamelExecutionException
<http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/CamelExecutionException.html>

I have done some tests and only catch this exception as written in the
documentation.

But during my testing i had a configuration issue due to dynamic
endpoint and I have seen that another exception can be thrown by this
method which were not managed by the code.
The following Exception is : NoSuchEndpointException

I have seen thas this exception can be a usual error :
http://camel.apache.org/exception-orgapachecamelnosuchendpointexception.html

My question is why this exception is not intercepted by the producer
template and wrapped in a CamelExecutionException as defined in the
prototype of the method ?

I know that I am using an old version of camel (2.4.0-fuse-00-00) but
I looked to sources and the method which throws the exception has not
change since 2.4.0.

DefaultProducerTemplate.java
----------------------------------------------------------------------------------------------------
protected Endpoint resolveMandatoryEndpoint(String endpointUri) {
       Endpoint endpoint = context.getEndpoint(endpointUri);
       if (endpoint == null) {
           throw new NoSuchEndpointException(endpointUri);
       }
       return endpoint;
}
----------------------------------------------------------------------------------------------------

Could it be a good idea to wrap this exception or add it in the
documentation in order to avoid missing error cases ?

Regards
Hervé

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message