使用 Camel 将输出从 POST 流式传输到 URL [英] Using Camel to stream output from a POST to a URL

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

问题描述

是否可以使用 Camel Stream 组件来读取 POST 到 URL 的输出?类似于:<to uri="stream:url?url=http://localhost:8080/mycontext/myservlet"/>我试过这个,但没有用.我需要将 JSON 对象发布到 URL 并处理返回的巨大有效负载,因此我需要将其流式传输到文件中,而无需先将其全部加载到内存中.CAMEL 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.

只要您的路由不强制 Camel 将消息负载自动转换为 String,您就可以在处理程序中自由实现任何专有流逻辑.换句话说,请确保您的处理程序,例如一个 bean 方法,在其方法签名中使用 InputStream 而不是 String.

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.

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

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