camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Gardner <ryeb...@gmail.com>
Subject Re: How to process continuous data stream
Date Wed, 06 May 2009 16:39:31 GMT

On May 6, 2009, at 9:50 AM, will mad wrote:

> Hi,
>
> I would like to write a route inside camel in order to handle the  
> following
> scenario:
>
> Send an http request to a distant system like this one : “GET
> /execute.cgi?opname=get_notifications HTTP/1.1”
>
> When receiving this HTTP request, the distant server responds, in a
> continuous-session HTTP reply. It means that the HTTP session  
> remains alive
> and is never closed. The distant system continuously sends messages.  
> So my
> camel component has to send the request and then continuously  
> receives data
> from the distant server. My problem is when I send the request, I only
> receive the first line of the message from the distant system, and  
> leave my
> route without processing other messages.
>
> Here is my route:
>
> from("file://c:/tmp/test?delete=true")
>
> .to("log:request")
>
>      .setBody(constant("GET /execute.cgi?opname=get_notifications
> HTTP/1.1\r\n\r\n"))
>
>      .to("mina:tcp://localhost:4122?textline=true&sync=false")
>
>      .to("log:response");

http://camel.apache.org/splitter.html

I saw this today while looking at the splitter for another use - but  
this seems to apply to what you want:

"Available as of Camel 1.5

You can split streams by enabling the streaming mode using the  
streaming builder method.

from 
("direct:streaming 
").split(body().tokenize(",")).streaming().to("activemq:my.parts");"
It would seem that in your case doing something like this:

.to("mina:tcp://localhost:4122? 
textline 
= 
true 
&sync 
=false").split(body().tokenize("\n")).streaming().to("log:response");

should do the trick.

Ryan
Mime
View raw message