骡子球衣下载大文件

时间:2013-12-17 06:38:22

标签: download jersey mule

我使用mule和jersey从ftp服务器下载文件,下载小文件没问题,大于100M的文件会在ftp服务器中出错并且不再下来,我写了一个jersey web项目并在tomcate中运行,可以下载600M大文件。 ftp服务器错误是:

java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
        at java.io.BufferedOutputStream.write(BufferedOutputStream.java:78)
        at org.apache.ftpserver.impl.IODataConnection.transfer(IODataConnection.java:268)
        at org.apache.ftpserver.impl.IODataConnection.transferToClient(IODataConnection.java:161)
        at org.apache.ftpserver.command.impl.RETR.execute(RETR.java:166)
        at org.apache.ftpserver.impl.DefaultFtpHandler.messageReceived(DefaultFtpHandler.java:210)
        at org.apache.ftpserver.listener.nio.FtpHandlerAdapter.messageReceived(FtpHandlerAdapter.java:61)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:716)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
        at org.apache.ftpserver.listener.nio.FtpLoggingFilter.messageReceived(FtpLoggingFilter.java:85)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
        at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:75)
        at org.apache.mina.filter.logging.MdcInjectionFilter.filter(MdcInjectionFilter.java:136)
        at org.apache.mina.filter.util.CommonEventFilter.messageReceived(CommonEventFilter.java:70)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
        at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:427)
        at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:245)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)
        at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:796)
        at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:75)
        at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)
        at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:780)
        at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:772)
        at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:714)
        at java.lang.Thread.run(Thread.java:662)

下载球衣代码

InputStream inputStream = ftpTransferUtil.download(ftpClient.getClient(), ftpFilePath); 
FormDataBodyPart fdbp = new FormDataBodyPart("payload",inputStream, MediaType.APPLICATION_OCTET_STREAM_TYPE);
FormDataMultiPart formDataMultiPart = new FormDataMultiPart();
formDataMultiPart.bodyPart(fdbp);
formDataMultiPart.field("app_id", appId);
//formDataMultiPart.field("file_size", file.length() + "");
formDataMultiPart.field("version", version);
formDataMultiPart.field("postfix", postfix);
formDataMultiPart.field("file_name", ftpFileName);
// 返回FormDataMultiPart对象
response = javax.ws.rs.core.Response.ok(formDataMultiPart).build();

mule jersey配置

<jersey:resources doc:name="REST Service">
        <component>
            <spring-object bean="fileTransferRest" />
        </component>
</jersey:resources>

1 个答案:

答案 0 :(得分:1)

堆栈跟踪中没有一个Mule类:看起来问题来自Apache FTP库。您可以将ftpTransferUtil配置为更长的超时时间吗?