camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: custom component synchronous processing
Date Sat, 21 Apr 2012 14:03:19 GMT
On Thu, Apr 19, 2012 at 8:32 PM, Jason Burkhardt <jburkhardt@gmail.com> wrote:
> Ugh, tough time deciding a proper title for this one.
> I have a custom component that basically implements a
> com.sun.net.httpserver.HttpServer - as such, it is consumer only.  My
> HttpConsumer component extends DefaultConsumer and basically takes the
> HttpServer and sets an HttpHandler object on it.  The HttpHandler object is
> created with a reference to the Processor from my HttpEndpoint (extends
> DefaultEndpoint).  When the handler receives a message it calls
> endpoint.createExchange and then processor.process(exchange).
> This is all well and good and a typical route looks like this:
>
> <route>
> <from uri="httpserver:myserver?someoptions"/>
> <log message="message ${body}"/>
> </route>
>
> The problem I'm having is we are receiving posts to the server at a rate of
>>= 3 per second and the log endpoint is getting them out of order from time
> to time.  I've debugged it to the point where the messages are in order
> right up until the point processor.process(exchange) is called, and then it
> falls into the realm of the InstrumentationProcessor, which processes it
> asynchronously.
> I've tried setting synchronous=true on my endpoint to no effect.
> Is there a better way to accomplish what I want?  I really need the messages
> to be in the same order they were received for processing later in the
> route, but thus far I have not been able to guarantee their order past the
> processor.process call.
> Any pointers/help would be appreciated.  If it makes a difference, I'm
> currently running camel 2.6.0
>

A http server is multi threaded and thus if you want any kind of
ordered processing further down by Camel.
You would need to process the message in sequence.

Either by sending the messages to a SEDA queue, and then have a route
that processes from the SEDA queue using
a single consumer.

Or you can use the threads EIP to limit the route to use a single thread.

Or let your consumer process the messages in sequence using a single thread.

But this will limit the scalability of your http service.



> Thanks,
> Jason Burkhardt
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/custom-component-synchronous-processing-tp5652471p5652471.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message