You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Christian Schäfer <sy...@yahoo.de> on 2013/03/11 14:44:03 UTC

Premature servlet response

Hello,

currently I have the problem of not beeing able to set servlet response which was generated by the last processor of my route:


servlet-consumer ->  processor1 -> onCompletion -> aggregate -> processor2 (response builder)


When I fire my test to the deployed servlet endpoint (camel 2.10.4 @ JBoss 7.1) it behaves in the order that:
1. body of processor1 is returned as http response
2. after that, processor2 starts which is too late as the response is still sent.

How to force the route to send the response only when processor2 is done?

 
regards
Christian  

Re: Premature servlet response

Posted by Christian Schäfer <sy...@yahoo.de>.
Thanks Claus for the suggestions.

Fortunately, in my use case (dynamic route building) it was possible to remove the aggegration step for the case of reponse generation 
Thus, it works now as expected.

 



________________________________
 Von: Claus Ibsen <cl...@gmail.com>
An: users@camel.apache.org 
Gesendet: 17:30 Mittwoch, 13.März 2013
Betreff: Re: Premature servlet response
 
On Wed, Mar 13, 2013 at 1:42 PM, Christian Schäfer <sy...@yahoo.de> wrote:
> Hi,
>
> I removed the on completion as suggested but the problem persists.
> Maybe a similar problem related to the aggregate and their completionHandlers?
>

If you use the aggregate eip then thats a stateful pattern, that when
it sends out an aggregated exchange, then that happens independently
from the caller threads. So you cannot send back a message to a
caller.

If you want to aggregate or something and send back a response to
caller. Then consider using content enricher eip. Or use a java bean
or whatever to do your own aggregation.


> regards
> Christian
>
>
> ________________________________
>  Von: Willem jiang <wi...@gmail.com>
> An: users@camel.apache.org; Christian Schäfer <sy...@yahoo.de>
> Gesendet: 3:27 Dienstag, 12.März 2013
> Betreff: Re: Premature servlet response
>
> Hi,
>
> Have you went through the onCompletion[1] page?
> If you want to processor2 take effect, you need to remove the onCompletion from your route.
>
> [1]http://camel.apache.org/oncompletion.html
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
>
>
> On Monday, March 11, 2013 at 9:44 PM, Christian Schäfer wrote:
>
>> Hello,
>>
>> currently I have the problem of not beeing able to set servlet response which was generated by the last processor of my route:
>>
>>
>> servlet-consumer -> processor1 -> onCompletion -> aggregate -> processor2 (response builder)
>>
>>
>> When I fire my test to the deployed servlet endpoint (camel 2.10.4 @ JBoss 7.1) it behaves in the order that:
>> 1. body of processor1 is returned as http response
>> 2. after that, processor2 starts which is too late as the response is still sent.
>>
>> How to force the route to send the response only when processor2 is done?
>>
>> regards
>> Christian



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Premature servlet response

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 13, 2013 at 1:42 PM, Christian Schäfer <sy...@yahoo.de> wrote:
> Hi,
>
> I removed the on completion as suggested but the problem persists.
> Maybe a similar problem related to the aggregate and their completionHandlers?
>

If you use the aggregate eip then thats a stateful pattern, that when
it sends out an aggregated exchange, then that happens independently
from the caller threads. So you cannot send back a message to a
caller.

If you want to aggregate or something and send back a response to
caller. Then consider using content enricher eip. Or use a java bean
or whatever to do your own aggregation.


> regards
> Christian
>
>
> ________________________________
>  Von: Willem jiang <wi...@gmail.com>
> An: users@camel.apache.org; Christian Schäfer <sy...@yahoo.de>
> Gesendet: 3:27 Dienstag, 12.März 2013
> Betreff: Re: Premature servlet response
>
> Hi,
>
> Have you went through the onCompletion[1] page?
> If you want to processor2 take effect, you need to remove the onCompletion from your route.
>
> [1]http://camel.apache.org/oncompletion.html
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://www.fusesource.com | http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
>           http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
>
>
> On Monday, March 11, 2013 at 9:44 PM, Christian Schäfer wrote:
>
>> Hello,
>>
>> currently I have the problem of not beeing able to set servlet response which was generated by the last processor of my route:
>>
>>
>> servlet-consumer -> processor1 -> onCompletion -> aggregate -> processor2 (response builder)
>>
>>
>> When I fire my test to the deployed servlet endpoint (camel 2.10.4 @ JBoss 7.1) it behaves in the order that:
>> 1. body of processor1 is returned as http response
>> 2. after that, processor2 starts which is too late as the response is still sent.
>>
>> How to force the route to send the response only when processor2 is done?
>>
>> regards
>> Christian



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Premature servlet response

Posted by Christian Schäfer <sy...@yahoo.de>.
Hi,

I removed the on completion as suggested but the problem persists.
Maybe a similar problem related to the aggregate and their completionHandlers?

regards
Christian


________________________________
 Von: Willem jiang <wi...@gmail.com>
An: users@camel.apache.org; Christian Schäfer <sy...@yahoo.de> 
Gesendet: 3:27 Dienstag, 12.März 2013
Betreff: Re: Premature servlet response
 
Hi,

Have you went through the onCompletion[1] page?
If you want to processor2 take effect, you need to remove the onCompletion from your route.

[1]http://camel.apache.org/oncompletion.html  

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Monday, March 11, 2013 at 9:44 PM, Christian Schäfer wrote:

> Hello,
>  
> currently I have the problem of not beeing able to set servlet response which was generated by the last processor of my route:
>  
>  
> servlet-consumer -> processor1 -> onCompletion -> aggregate -> processor2 (response builder)
>  
>  
> When I fire my test to the deployed servlet endpoint (camel 2.10.4 @ JBoss 7.1) it behaves in the order that:
> 1. body of processor1 is returned as http response
> 2. after that, processor2 starts which is too late as the response is still sent.
>  
> How to force the route to send the response only when processor2 is done?
>  
> regards
> Christian  

Re: Premature servlet response

Posted by Willem jiang <wi...@gmail.com>.
Hi,

Have you went through the onCompletion[1] page?
If you want to processor2 take effect, you need to remove the onCompletion from your route.

[1]http://camel.apache.org/oncompletion.html  

--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem





On Monday, March 11, 2013 at 9:44 PM, Christian Schäfer wrote:

> Hello,
>  
> currently I have the problem of not beeing able to set servlet response which was generated by the last processor of my route:
>  
>  
> servlet-consumer -> processor1 -> onCompletion -> aggregate -> processor2 (response builder)
>  
>  
> When I fire my test to the deployed servlet endpoint (camel 2.10.4 @ JBoss 7.1) it behaves in the order that:
> 1. body of processor1 is returned as http response
> 2. after that, processor2 starts which is too late as the response is still sent.
>  
> How to force the route to send the response only when processor2 is done?
>  
> regards
> Christian