开发者

Stream HTTP GET response to file in Mule

开发者 https://www.devze.com 2023-03-29 17:17 出处:网络
How do you make a HTTP GET request in Mule, and then stream the response to a file?My application stores the entire response in memory, but the response can be large, so this needs to be fixed.I want

How do you make a HTTP GET request in Mule, and then stream the response to a file? My application stores the entire response in memory, but the response can be large, so this needs to be fixed. I want to save the response to a temporary file, and then stream the file contents back to the client.

Right now, I'm doing:

Stri开发者_如何学Cng restUrl = "http://www.url.com";
UMOEventContext context = RequestContext.getEventContext();
GetMethod method = new GetMethod(restUrl);          
UMOMessage muleMessage = new MuleMessage(method);
muleMessage.setProperty(RestServiceWrapper.REST_SERVICE_URL, restUrl);

UMOMessage result = context.sendEvent(muleMessage, new MuleEndpointURI("vm://identifier")); //OutOfMemoryException
String body = result.getPayloadAsString();

I'm using Mule 1.3.3 and cannot upgrade. Thank you.

0

精彩评论

暂无评论...
验证码 换一张
取 消