camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raul Kripalani <r...@evosent.com>
Subject Re: camel-cxfrs and AsyncResponse
Date Tue, 26 Aug 2014 22:28:08 GMT
Hey Michael,

Can you try setting the 'synchronous' property to 'true' in the
rsServer bean? This will force the component to take the sync
execution path and circumvent using Continuations.

You need to use a <cxf:properties /> block. I don't have any examples
handy and I cannot write source code now, but you'll find examples
online.

Thanks,
Raúl.

Sent from my iPad

> On 26 Aug 2014, at 17:05, Michael Bannii <Michael.Bannii@evry.com> wrote:
>
> It appears I already have SelectChannelConnector set up in my pom.xml and still have
the issue...
>
> I use  jetty-maven-plugin 8.1.15.v20140411 with CXF 2.7.11 and Camel v2.13.2.
> The processing chain appears to be:  jetty -> some filters -> cxf -> cxfrs ->
camel.
>
> Also when I set a breakpoint inside my processor I see that a whole HTTP thread gets
blocked by it (which is probably not what I want, and I want to arrange a threadless wait
when calling backend in my processor), and in stack there is
>   CxfRsInvoker.performInvocation(Exchange, Object, Method, Object[]) line: 56
> and the continuation object there is an instance of org.apache.cxf.transport.http.Servlet3ContinuationProvider$Servlet3Continuation.
So at least some Continuation is being used.
>
>
> -----Original Message-----
> From: Raul Kripalani [mailto:raul@evosent.com]
> Sent: 26 серпня 2014 р. 17:51
> To: users@camel.apache.org
> Subject: Re: camel-cxfrs and AsyncResponse
>
> I came across this issue recently and the culprit was the default etc/jetty.xml configuration
packaged with Apache ServiceMix, which by default uses the BlockingChannelConnector, as explained
in the inline XML comment.
>
> This connector does not support Jetty Continuations, therefore it is not capable of handling
an async response.
>
> You don't specify what runtime container you're using, but if you use Apache ServiceMix
or Apache Karaf with Pax Web you can be facing the same problem.
>
> If you swap the BlockingChannelConnector for a SelectChannelConnector, it should work.
>
> Regards,
>
> *Raúl Kripalani*
> Apache Camel PMC Member & Committer | Enterprise Architect, Open Source Integration
specialist http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
> http://blog.raulkr.net | twitter: @raulvk
>
> On Tue, Aug 26, 2014 at 3:21 PM, Michael Bannii <Michael.Bannii@evry.com>
> wrote:
>
>> Hi,
>>
>> I use camel-cxfrs with a JAX-RS2 resource java class having a method
>> declared in async way using AsyncResponse, like this:
>>
>>    <camel:route>
>>        <camel:from
>> uri="cxfrs://bean://testRsServer?bindingStyle=SimpleConsumer" />
>>        .........a code here that finally does
>> exchange.getOut().setBody(response);
>>    </camel:route>
>>
>>    <camelcxf:rsServer id="testRsServer" address="/test"
>> serviceClass="foo.bar.TestResource">
>>
>>    @Path("/") @Produces({MediaType.APPLICATION_JSON})
>>    public class TestResource {
>>        @POST @Path("/something")
>>        public void addAccount(@Multipart(value = "myDomainObject")
>> final String myDomainObject, @Suspended final AsyncResponse ar) {
>>            throw new RuntimeException("Camel does not call it anyway");
>>        }
>>    }
>>
>>
>> When I invoke the resource, Camel invokes the route, however no REST
>> response is sent back to client for some reason... Looks like Camel is
>> not calling AsyncResponse.resume()?
>>
>> If I change the resource declaration to sync-way like below, i.e. drop
>> AsyncResponse and change response type from void to MyResponse, then
>> REST response is sent back as expected.
>>
>>        @POST @Path("/something")
>>        public MyResponse addAccount(@Multipart(value =
>> "myDomainObject") final String myDomainObject) {
>>            throw new RuntimeException("Camel does not call it anyway");
>>        }
>>
>> Why is such behavior? Am I missing something?
>>
>>
>> --
>> Best regards
>>
>>

Mime
View raw message