You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by SwenVogel <sw...@ypsystems.de> on 2009/10/13 12:26:03 UTC

Jetty asynchronus and parallel processing

Hi,

i want to receive data over an HTTP-POST request and immediately return, so
the processing
is done asynchronously. The client should receive a HTTP status code 200
without any response data.

I have the following two routes:

1.
The route that receives the data, set some simple properties, and send the
data
to the message processing route.

from(“jetty:http:/localhost:8080/test“)
    .setProperty(…)
    .setProperty(…)
    .inOnly(“seda:messageProcessing“)

2.
The message processing route do some post and pre processings and sends the
message to
endpoints that are determined at runtime, therefore i used the routing slip.

from(“seda:messageProcessing“)
    .threads()
    .process(…)
    .routingSlip()
    .process()

In the second route (seda:messageProcessing) i used the threads DSL to
enable parallel  processing,
but i cannot figure out if this ist the correct way!

The problem with this solution ist that the jetty endpoint always returns
the request data as response data.

So when i send:

<echo>
	Apache Camel is cool!
</echo>

I get back:

<echo>
	Apache Camel is cool!
</echo>


-- 
View this message in context: http://www.nabble.com/Jetty-asynchronus-and-parallel-processing-tp25870376p25870376.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Jetty asynchronus and parallel processing

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Oct 13, 2009 at 2:21 PM, SwenVogel <sw...@ypsystems.de> wrote:
>
> Thats really easy!
>
> And is the combination of the seda route and thread DSL correct?

The seda consumer supports concurrency so you can just do:

from("seda:foo?concurrentConsumers=20").to(x)

Then you do not need the .threads() in the DSL.

Details at:
http://camel.apache.org/seda


>
>
> --
> View this message in context: http://www.nabble.com/Jetty-asynchronus-and-parallel-processing-tp25870376p25871863.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Jetty asynchronus and parallel processing

Posted by SwenVogel <sw...@ypsystems.de>.
Thats really easy!

And is the combination of the seda route and thread DSL correct?


-- 
View this message in context: http://www.nabble.com/Jetty-asynchronus-and-parallel-processing-tp25870376p25871863.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Jetty asynchronus and parallel processing

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Oct 13, 2009 at 12:26 PM, SwenVogel <sw...@ypsystems.de> wrote:
>
> Hi,
>
> i want to receive data over an HTTP-POST request and immediately return, so
> the processing
> is done asynchronously. The client should receive a HTTP status code 200
> without any response data.
>
> I have the following two routes:
>
> 1.
> The route that receives the data, set some simple properties, and send the
> data
> to the message processing route.
>
> from(“jetty:http:/localhost:8080/test“)
>    .setProperty(…)
>    .setProperty(…)
>    .inOnly(“seda:messageProcessing“)
>
> 2.
> The message processing route do some post and pre processings and sends the
> message to
> endpoints that are determined at runtime, therefore i used the routing slip.
>
> from(“seda:messageProcessing“)
>    .threads()
>    .process(…)
>    .routingSlip()
>    .process()
>
> In the second route (seda:messageProcessing) i used the threads DSL to
> enable parallel  processing,
> but i cannot figure out if this ist the correct way!
>
> The problem with this solution ist that the jetty endpoint always returns
> the request data as response data.
>
> So when i send:
>
> <echo>
>        Apache Camel is cool!
> </echo>
>
> I get back:
>
> <echo>
>        Apache Camel is cool!
> </echo>
>

Just transform the message to what you want to return, in your case an
empty body then do

.transform(constant(""));

or maybe even a null
.transform(null);

 from(“jetty:http:/localhost:8080/test“)
    .setProperty(…)
    .setProperty(…)
    .inOnly(“seda:messageProcessing“)
    .transform(constant("")); // set empty response to http client





>
> --
> View this message in context: http://www.nabble.com/Jetty-asynchronus-and-parallel-processing-tp25870376p25870376.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus