使用骆驼流从POST输出到URL [英] Using Camel to stream output from a POST to a URL

查看:156
本文介绍了使用骆驼流从POST输出到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使用骆驼流组件读取POST的输出到一个URL?喜欢的东西:<到URI =流:URL URL = HTTP://本地主机:8080 / mycontext / myservlet/>
我试过,但没有奏效。我需要张贴JSON对象到一个URL和处理返回一个巨大的有效载荷,所以我需要它被传输到一个文件,而无需首先加载它全部在内存中。是否有骆驼DSL的替代品或者我应该以某种方式使用一个bean,例如使用HttpURLConnection类,做流?

Is it possible to use the Camel Stream Component to read output of a POST to a URL? Something like: <to uri="stream:url?url=http://localhost:8080/mycontext/myservlet"/> I tried this but it did not work. I need to post a JSON object to a URL and process a huge payload being returned, so I need it to be streamed to a file without loading it all in memory first. Are there alternatives in the CAMEL DSLs or should I be using a bean somehow, e.g. using a HttpUrlConnection, to do the streaming?

推荐答案

只需使用 HTTP模块 - 它支持POST请求,进而会给你一个的InputStream 的回报

Simply use the http module - it does support POST requests and furthermore will give you an InputStream in return.

只要你的路线并不强制骆驼自动将邮件转换为有效载荷字符串,你可以自由地实现你的处理器的任何专有流逻辑。换句话说,请确保您的处理器,例如bean方法,使用的InputStream ,而不是字符串在其方法签名。

As long as your route does not force Camel to auto-convert the message payload to String, you are free to implement any proprietary streaming logic in your handler. In other words, make sure your handler, e.g. a bean method, uses InputStream rather than String in its method signature.

这篇关于使用骆驼流从POST输出到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆