Reputation: 3690
I was on the look for an integration framework. And guess out I have found one - Apache Camel. This framework is cool. But for one requirement of mine, I am not able to place the components in the right order. The requirement has following stages -
Authentication
Authorization
PreProcessing etc.
So when a request comes I need to authenticate, authorize, preprocess etc. The problem is each of these step can fails and with that I do not want the execution flow to continue, rather should return back with some failure message. I was trying something of this sort -
from("jetty").choice().
when(Auth.isAuthenticated()).
// proceed to authorization
// proceed to preprocessing
otherwise()
// do something
endChoice();
But the problem over here is authorization stage might also fail, then the preprocessing step should not be executed and authorization stage itself should return a failure message. Is it possible?
Upvotes: 1
Views: 1268
Reputation: 3193
Yes, this is standard Camel error handling. Please see the error and exception handling documentation. https://camel.apache.org/exception-clause.html
Another thing I would probably do is split your functionality in separate routes. Put the authentication, authorization and preprocessing in separate routes. One big benefit of this is that they are not dependent on each other so other flows which need this functionality can simply call the routes and you can reuse them. Also if something does go wrong in authentication, then the message never gets to authentication route etc.
Upvotes: 2