Hi,
As we approach the 2.0, there is one more hanging issue I would like
addressed, if possible. It's the thorny issue of Faults and
Exceptions that started in
http://issues.apache.org/activemq/browse/CAMEL-316 (see also the
related nabble thread linked in the issue description).
I am less concerned about how the DefaultExchange is implemented and I
hope to reach an agreement on what the Exchange api should be (please
find the list of Exchange methods below).
As far as faults/exceptions are concerned, Roman thinks that the whole
concept of in/out/fault/exception is artificial, and only one payload
(message) api should be enough (Roman please correct me if I
misinterpret your position). My opinion is that we *must* distinguish
between persistent (fault) and transient (exception) errors for the
simple reason that they have different semantics. As Roman correctly
points out, faults are more like outputs, have more of application
level semantics and are normally handled by the client, where
exceptions (transient errors) are something camel could try to recover
from, without much knowledge about the application. I think that the
presence of fault in the camel api is not due to it being explicitly
modeled by jbi and wsdl, as Roman suggests, and Camel simply copying
that, but it's modeled in Camel for the same reason it's modeled in
jbi and wsdl, to differentiate transient from persistent errors in a
non ambiguous way.
If we were to go with only get/setMessage() api, we would still need
methods (or some ways) to distinguish between the kind of message we
are dealing with (in/out/fault/exception) so we'd only move the
problem somewhere else.
So the question becomes if we leave the api the way it is, or we
replace the get/setFault apis with get/setOut, in which case we'll
need something like:
boolean isFault();
method in the Message api or keep the hasFault() method on the Exchange.
Thoughts?
ExchangePattern getPattern();
void setPattern(ExchangePattern pattern);
Object getProperty(String name);
<T> T getProperty(String name, Class<T> type);
void setProperty(String name, Object value);
Object removeProperty(String name);
Map<String, Object> getProperties();
Message getIn();
void setIn(Message in);
Message getOut();
boolean hasOut();
Message getOut(boolean lazyCreate);
void setOut(Message out);
Message getFault();
boolean hasFault();
Message getFault(boolean lazyCreate);
void removeFault();
// removeFault() is only used in one place
Exception getException();
<T> T getException(Class<T> type);
void setException(Exception e);
boolean isFailed();
boolean isTransacted();
boolean isRollbackOnly();
CamelContext getContext();
Exchange newInstance();
Exchange copy();
Exchange newCopy(boolean handoverOnCompletion);
void copyFrom(Exchange source);
Endpoint getFromEndpoint();
void setFromEndpoint(Endpoint fromEndpoint);
UnitOfWork getUnitOfWork();
void setUnitOfWork(UnitOfWork unitOfWork);
String getExchangeId();
void setExchangeId(String id);
void addOnCompletion(Synchronization onCompletion);