Using Camel to stream output from a POST to a URL

◇◆丶佛笑我妖孽 提交于 2019-12-11 22:46:30

问题


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?


回答1:


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

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.



来源:https://stackoverflow.com/questions/33684618/using-camel-to-stream-output-from-a-post-to-a-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!