I think it would be useful to add declarative exception handling to ServiceMix. The usefullness of such a feature can be seen from the following simple use case involving a client submitting an order to a fulfillment company:
1) The use case starts when the client sends an order to an HTTP endpoint exposed in ServiceMix. The message representing the order is routed to a business service component. 2) The business service component attempts to process the Order and save it to a database. However, an exception occurs during this process and gets bubbled up. The fulfillment company would like to be notified via email when an order fails to be processed. Since we have configured the business service component to pass all exceptions to an email component, the flow moves to step 3. 3) The email component sends out an email notification to the fulfillment company indicating that an error occurred while processing the order. 4) After the email has been sent out, the flow moves to another component that returns a more user friendly error message to the original HTTP endpoint. This way we do not send back a hard to read error message to the client. The purpose of such a flow is that we handle exceptions more gracefully than currently is supported by ServiceMix. Instead of bubbling up exceptions to the calling component, we should allow components to change the flow of a message when an exception occurs. The configuration could look something like the following: <activationSpec componentName="businessServiceComponent" service="example:businessService" exceptionDestionationService="example:emailService"> <sm:component> <bean class="com.mycompany.MyClass"/> </sm:component> </activationSpec> Alternatively, perhaps we can just use AOP to catch exceptions that occur within a component: <sm:exceptionHandler exceptionType="javax.jbi.messaging.MessagingException" destinationService="example:emailService"> <activationSpec componentName="businessServiceComponent" service="example:businessService"> <sm:component> <bean class="com.mycompany.MyClass"/> </sm:component> </activationSpec> </sm:exceptionHandler> Here are a few concerns of mine: 1) The problem with the first example configuration is that it doesn't allow you to get creative with how certain types of exceptions are handled, it just acts like a catch all. We may need to create a more flexible way of configuring exception handling. 2) Because of the way JBI service units/assemblies are packaged and deployed, would this work? Is there any discussion on declaratively handling exceptions in the JBI spec? Regards, Jeff -- View this message in context: http://www.nabble.com/Declarative-Exception-Handling-in-ServiceMix-tf2161788.html#a5974450 Sent from the ServiceMix - Dev forum at Nabble.com.