问题
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