Apache camel 骆驼';在通过CXFRS组件将数据发送回REST客户端之前,s FileInputStreamCache已关闭

Apache camel 骆驼';在通过CXFRS组件将数据发送回REST客户端之前,s FileInputStreamCache已关闭,apache-camel,cxfrs,camel-cxf,Apache Camel,Cxfrs,Camel Cxf,我使用camel cxfrs组件映射一个简单的REST-GET操作,该操作返回从外部资源提取的数据。在我决定启用“streamCache”之前,一切都很正常,因为要返回的数据有时可能非常大(高达50MB),我们不想将其加载到内存中,否则,当同时执行多个请求时,我们将耗尽内存! 因此,我配置了DefaultStreamCachingStrategy来定义何时将数据流传输到tmp文件(例如大于1MB的数据) 这工作正常,一旦我的数据从外部资源(数据库中的blob!!)中获取,它就会流式输出回调用者,

我使用camel cxfrs组件映射一个简单的REST-GET操作,该操作返回从外部资源提取的数据。在我决定启用“streamCache”之前,一切都很正常,因为要返回的数据有时可能非常大(高达50MB),我们不想将其加载到内存中,否则,当同时执行多个请求时,我们将耗尽内存! 因此,我配置了DefaultStreamCachingStrategy来定义何时将数据流传输到tmp文件(例如大于1MB的数据)

这工作正常,一旦我的数据从外部资源(数据库中的blob!!)中获取,它就会流式输出回调用者,因为数据大于阈值,Camel正在将我的inputstream转换为FileInputStreamCache,这很好。。。直到响应准备好通过CXF组件返回给调用方!由于消息被传递到CXF组件,因此不再需要Camel交换(输出消息保留Camel上下文),因此在内容完全返回到REST客户端之前,创建的tmp文件由Camel删除(由其TempFileManager实现)
这会导致IOException,因为CXF组件正在尝试从inputstream(刚刚被Camel关闭)向http客户端读取数据

你知道怎么解决这个问题吗??我需要保持tmp文件处于打开状态,直到所有响应数据都可以发送回REST客户机。但在发送响应后,必须关闭并删除is

下面是我的Camel上下文和一些bean是如何定义的(没有显示所有内容):


你用什么版本的骆驼?好问题!!我怎么忘了提到这些基本信息!Camel 2.17、java 8、RHEL 6.8、JBoss Fuse 6.3I在Camel的开发者论坛上发现了类似的问题:它看起来很相似,但使用Camel cxfrs组件而不是jetty作为输入端点。
<!-- ... -->
<cxf:rsServer address="/path" id="rsServer">
    <cxf:providers>
        <!-- ... -->
    </cxf:providers>
    <cxf:serviceBeans>
        <ref bean="resourcesEndpoint"/>
    </cxf:serviceBeans>
    <!-- ... -->
</cxf:rsServer>
<!-- ... -->

<bean class="org.apache.camel.impl.DefaultStreamCachingStrategy" id="streamStrategy">
    <property name="enabled" value="true"/>
    <property name="bufferSize" value="512000"/>
    <property name="spoolThreshold" value="512000"/>
    <property name="spoolUsedHeapMemoryThreshold" value="8}"/>
    <property name="spoolUsedHeapMemoryLimit" value="Max"/>
    <property name="removeSpoolDirectoryWhenStopping" value="true"/>
    <property name="anySpoolRules" value="true"/>
</bean>
<!-- ... -->

<camelContext id="context" streamCache="true" trace="false" useBreadcrumb="true" useMDCLogging="true" xmlns="http://camel.apache.org/schema/spring">
    <!-- ... -->
    <route id="mainRoute" >
        <from id="fromCXFEndpoint" uri="cxfrs:bean:rsServer?bindingStyle=SimpleConsumer"/>
        <recipientList id="_recipientList1">
            <simple>direct:${header.operationName}</simple>
        </recipientList>
    </route>
    <route id="downloadDataRoute" >
        <from id="fromDownloadDataCXF" uri="direct:downloadData"/>
        <!-- ... -->
        <!-- Performing data fetching... not showing everything here! -->
        <!-- ... -->
    </route>
</camelContext>
@Path("/resources")
@Component
@Service
public class ResourcesEndpoint {

    @GET
    @Path("/data/{guid}")
    @Produces({MediaType.TEXT_PLAIN, MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM})
    public StreamingOutput downloadData(@PathParam("guid") String guid) {
        return null;
    }
}