Yeah! There is a drawback! :-(

Exchange.ROUTE_STOP stops completely the processing of the exchange, not
only the current route!

My routes are something like this:

<route id="httpRoute">
<from uri="jetty:http://0.0.0.0:8090/mobile"; />
<to uri="direct:gsonDeserialization" />
</route>

<route id="serializationRoute">
<from uri="direct:gsonDeserialization" />
<process ref="gsonDeserializationProcessor" />
<to uri="direct:toMainService" />
<process ref="gsonSerializationProcessor" />
</route>

<route id="mainLogicRoute">
<from uri="direct:toMainService" />
<process ref="authenticatedChannelProcessor" />
<to uri="bean:mainService" />
</route>


I've implemented Exchange.ROUTE_STOP into the "authenticatedChannelProcessor",
which works in JUnit tests, but when I integrate it into this routes, it
does not only stops mainLogicRoute by skipping <to uri="bean:mainService"
/>, it also skips <process ref="gsonSerializationProcessor" /> in the
serializationRoute...

I'm thinking to change by setting a property on my own, and filter <to
uri="bean:mainService" /> if this property is not available...

Suggestions?

Bye!





Il giorno ven 17 apr 2015 alle ore 11:36 Cristiano Costantini <
[email protected]> ha scritto:

> Hi Willem, hi all,
> thank you for your support,
>
> I wanted to avoid to throw an exception, because then I have to handle it
> in order to return proper payload (I want empty payload if the user is not
> authenticated) in the response.
>
> I've maybe found a different approach that I am now investigating:
> As I am processing the message in a custom Processor (who both performs
> authentication and checks authorization), I've discovered that I can stop
> the processing in the Processor by setting a property on the exchange:
>
> exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
>
> So if the message is not authorized, I first set the body to my empty body
> (I set to a Collections.emptyList() ) and then stop it.
>
> The Junit tests now are working, I now integrate it to check if there are
> other issues.
>
> Feedback on the approach of using "Exchange.ROUTE_STOP" is welcome :-)
>
> Bye,
> Cristiano
>
>
>
> Il giorno gio 16 apr 2015 alle ore 17:19 Willem Jiang <
> [email protected]> ha scritto:
>
>> I think you can just throw out the authentication failure exception and
>> you can use the error handler to setup some kind of reject exception for
>> the response to use.
>>
>> --
>> Willem Jiang
>>
>> Red Hat, Inc.
>> Web: http://www.redhat.com
>> Blog: http://willemjiang.blogspot.com (English)
>> http://jnn.iteye.com (Chinese)
>> Twitter: willemjiang
>> Weibo: 姜宁willem
>>
>>
>>
>> On April 16, 2015 at 4:15:38 PM, Cristiano Costantini (
>> [email protected]) wrote:
>> > Hello,
>> >
>> > I was searching to implement a "Pipes and Filter" EIP that, as the
>> picture
>> > illustrated in http://camel.apache.org/pipes-and-filters.html, it has a
>> > step that "Authenticates" the exchange.
>> >
>> > I have not however figured out how to manage a failed authentication:
>> > how do I best implement the rejection of the exchange to be further
>> > processed by subsequents endpoints?
>> >
>> > I'm confused as my exchange is an InOut, so I cannot simply abort the
>> > processing, I need to send back some output (either an empty response or
>> > error code) to the initial from endpoint...
>> >
>> > Any suggestion?
>> > thanks,
>> > Cristiano
>> >
>>
>>

Reply via email to