Camel REST DSL-内容长度分隔的消息正文的过早终止

时间:2018-12-10 18:19:23

标签: apache-camel

我正在使用Camel Rest DSL构建端点以用作不同网络之间的代理。

我创建了2个端点。代码下方:

第一:

restConfiguration().host("localhost").component("undertow").bindingMode(RestBindingMode.off);
    rest("/endpoint?{1param}&{2param}")
    .get("/")
        .route().routeId("Ednpoint1")
            .autoStartup(true)
            .setProperty("uri", simple("http4://0.0.0.0:8080/endpoint?1param=${header.1param}&2param=${header.2param}"))
            .setHeader(Exchange.HTTP_METHOD, constant("GET"))
            .removeHeaders("CamelHttp*")
       .toD("${header.uri}").endRest().responseMessage().message("${body}");

第二:

restConfiguration().host("localhost").component("undertow").bindingMode(RestBindingMode.off);
        rest("/endpoint?{param1}&{param2}")
        .get("/")
            .route().routeId("Endpoint2")
                .autoStartup(true)
                .setProperty("uri", simple("http4://endpoint-destionation/service?dhi=${header.param1}&dhf=${header.param2}"))
                .setHeader(Exchange.HTTP_METHOD, constant("GET"))
                .removeHeaders("*")
           .toD("${header.uri}").endRest().responseMessage().message("${body}");

我当前遇到以下错误:

org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 146541; received: 54482
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:180)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:150)
at org.apache.camel.util.IOHelper.copy(IOHelper.java:219)
at org.apache.camel.util.IOHelper.copy(IOHelper.java:174)
at org.apache.camel.util.IOHelper.copy(IOHelper.java:170)
at org.apache.camel.component.http4.HttpProducer.doExtractResponseBodyAsStream(HttpProducer.java:414)
at org.apache.camel.component.http4.HttpProducer.extractResponseBody(HttpProducer.java:397)
at org.apache.camel.component.http4.HttpProducer.populateResponse(HttpProducer.java:242)
at org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:203)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.processor.SendDynamicProcessor$1.doInAsyncProducer(SendDynamicProcessor.java:178)
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:445)
at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:160)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
at org.apache.camel.component.undertow.UndertowConsumer.handleRequest(UndertowConsumer.java:126)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:748)

有没有办法绕过骆驼的问题?谢谢!

1 个答案:

答案 0 :(得分:0)

发现了问题。 就我而言,我使用Wildfly 13部署我的骆驼路线。 问题出在HTTP侦听器Undertow组件内的字段Send Buffer。

Configuration⇒Subsystems⇒Web (Undertow)⇒Server ⇒default-server 
Listener⇒HTTP Listener

我将值更改为10000000(千字节),现在可以正常工作。