You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Chinababu Illa <ch...@gmail.com> on 2013/05/13 13:38:43 UTC

Streaming a PDF from remote machine

Hi All,

I have a requirement to read a pdf as binary stream from remote application
within specified time. 
My application code is using BufferedInputStream to read from remote
application, code is implemented in Java. 

While reading the data, I need to apply 2 different timeouts:
1) a timeout for individual bufferedInputStream.read() (if this waits
longer, it will be timedout)
2) a timeout for entire file to be download (say 2 min, if the file is not
completely downloaded within 2 min,  then timeout)

I have a solution using timeout calculation manually, but it is not elegant
solution.
So wanted to know if this can be done using camel. I looked into stream
component but didn't quite understood.

Please let me know if above 2 requirements can be implemented using camel.

Note: None of the two applications are using Files here. My remote
application gets the stream data from different application.

Thanks,
Chinna




--
View this message in context: http://camel.465427.n5.nabble.com/Streaming-a-PDF-from-remote-machine-tp5732401.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Streaming a PDF from remote machine

Posted by Chinababu Illa <ch...@gmail.com>.
Thanks Willem.

Regards,
Chinna



--
View this message in context: http://camel.465427.n5.nabble.com/Streaming-a-PDF-from-remote-machine-tp5732401p5732571.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Streaming a PDF from remote machine

Posted by Willem jiang <wi...@gmail.com>.
I'm afraid you have to implement the timeout mechanism yourself.
I don't aware camel provides this feature out of box.

BTW, I think the solution2 that you have is a good one.   

--  
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 Tuesday, May 14, 2013 at 4:46 PM, Chinababu Illa wrote:

> Thanks Willem.
>  
> A bit more details on the problem.
>  
> There are 3 applications involved in this issue. FrontEnd, Link and Host.
> Link sits between FrontEnd and Host. When FrontEnd sends a request (http
> post) to Link it in turn sends a request to Host and also creates two
> streams one to read from Host and other one to send the same data to
> FrontEnd. Due to slow streaming from Host, the FrontEnd to download the file
> is taking longer time. And we cannot afford user waiting for that longer.
> So, want to terminate downloading after certain period of time.
>  
> Please find details below for your points.
>  
> *Are you using FTP to download the file?*
> - /No./
>  
> *I'm not sure how the BufferedInputStream is involved. *
> - /FrontEnd reads response as Stream (InputStream) is how
> BufferedInputStream involved here.
> We are wrapping InputStream with BufferedInputStream./
>  
> *If the file is downloaded, the BufferedInputStream will never time out.*
> - /Consider a case where file is still downloading and read never gets
> timedout as it is getting data (a less data) for every read/
>  
> *If the BufferedInputStream has the timeout mechanism, I don't think you
> need to check if the File is download.*
> - /BufferedInputStream has the timeout mechanism but it will never timeout
> as it gets data within timeout period./
>  
>  
> I have already got two solutions with me.
>  
> 1) Implementing timeout manually (not a good idea, not elegant solution)
> 2) Create a message listener send a message to start downloading, send a
> message to terminate downloading after certain time.
> 3) Looking if Camel can solve this by auto imposing timeout.
>  
> So, please let me know if Camel has a solution for this kind of problems. If
> so, point me what to look into.
>  
> Thanks,
> Chinna
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Streaming-a-PDF-from-remote-machine-tp5732401p5732474.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Streaming a PDF from remote machine

Posted by Chinababu Illa <ch...@gmail.com>.
Thanks Willem.

A bit more details on the problem.

There are 3 applications involved in this issue. FrontEnd, Link and Host.
Link sits between FrontEnd and Host. When FrontEnd sends a request (http
post) to Link it in turn sends a request to Host and also creates two
streams one to read from Host and other one to send the same data to
FrontEnd. Due to slow streaming from Host, the FrontEnd to download the file
is taking longer time. And we cannot afford user waiting for that longer.
So, want to terminate downloading after certain period of time.

Please find details below for your points.

*Are you using FTP to download the file?*
- /No./

*I'm not sure how the BufferedInputStream is involved.  *
- /FrontEnd reads response as Stream (InputStream) is how
BufferedInputStream involved here.
   We are wrapping InputStream with BufferedInputStream./

*If the file is downloaded, the BufferedInputStream will never time out.*
- /Consider a case where file is still downloading and read never gets
timedout as it is getting data (a less data) for every read/

*If the BufferedInputStream has the timeout mechanism, I don't think you
need to check if the File is download.*
- /BufferedInputStream has the timeout mechanism but it will never timeout
as it gets data within timeout period./


I have already got two solutions with me.

1) Implementing timeout manually (not a good idea, not elegant solution)
2) Create a message listener send a message to start downloading, send a
message to terminate downloading after certain time.
3) Looking if Camel can solve this by auto imposing timeout.

So, please let me know if Camel has a solution for this kind of problems. If
so, point me what to look into.

Thanks,
Chinna





--
View this message in context: http://camel.465427.n5.nabble.com/Streaming-a-PDF-from-remote-machine-tp5732401p5732474.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Streaming a PDF from remote machine

Posted by Willem jiang <wi...@gmail.com>.
Are you using FTP to download the file?
I'm not sure how the BufferedInputStream is involved.  
If the file is downloaded, the BufferedInputStream will never time out.
If the BufferedInputStream has the timeout mechanism, I don't think you need to check if the File is download.


--  
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, May 13, 2013 at 7:38 PM, Chinababu Illa wrote:

> Hi All,
>  
> I have a requirement to read a pdf as binary stream from remote application
> within specified time.  
> My application code is using BufferedInputStream to read from remote
> application, code is implemented in Java.  
>  
> While reading the data, I need to apply 2 different timeouts:
> 1) a timeout for individual bufferedInputStream.read() (if this waits
> longer, it will be timedout)
> 2) a timeout for entire file to be download (say 2 min, if the file is not
> completely downloaded within 2 min, then timeout)
>  
> I have a solution using timeout calculation manually, but it is not elegant
> solution.
> So wanted to know if this can be done using camel. I looked into stream
> component but didn't quite understood.
>  
> Please let me know if above 2 requirements can be implemented using camel.
>  
> Note: None of the two applications are using Files here. My remote
> application gets the stream data from different application.
>  
> Thanks,
> Chinna
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Streaming-a-PDF-from-remote-machine-tp5732401.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).