Search code examples
javaapacherestapache-camelcxf

GET HTTP operation via apache Camel fails when Rest Request URI too long


I am using apache rest CXF with camel in my project. There are number of cases where the length of request URI for rest is too longs and after a certain length camel always though HTTP operation failed exception like below with

statusCode: 400 
        at org.apache.camel.component.http.HttpProducer.populateHttpOperationFailedException(HttpProducer.java:230) ~[camel-http-2.13.1.jar:2.13.1] 
        at org.apache.camel.component.http.HttpProducer.process(HttpProducer.java:156) ~[camel-http-2.13.1.jar:2.13.1] 
        at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:113) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) ~[camel-core-2.13.1.jar:2.13.1]l 
        at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:111) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:80) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) ~[camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.component.seda.SedaConsumer.sendToConsumers(SedaConsumer.java:291) [camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.component.seda.SedaConsumer.doRun(SedaConsumer.java:200) [camel-core-2.13.1.jar:2.13.1] 
        at org.apache.camel.component.seda.SedaConsumer.run(SedaConsumer.java:147) [camel-core-2.13.1.jar:2.13.1] 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101] 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101] 
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101] 

So is there any way, we can pass the length parameter explicitly in header before sending the request or any other configuration for setting maximum length of request URI. For workaround i just replaced camel call with HttpConnection and it worked fine, this means camel has some restriction over requested URI length.

I placed the request at link

Camel code :

.choice()
                .when(header(ReservationConstant.CALL_ENDECA_FOR_LAR_FACETS).isEqualTo(Boolean.TRUE))
                .setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.GET))
                .setHeader(Exchange.HTTP_PATH, constant(ReservationConstant.ENDECA_GUIDED_SEARCH_SERVICE))
                .setBody(simple(StringUtils.EMPTY))
                //.to("cxfrs:bean:endecaLocationKeyRSClient?throwExceptionOnFailure=false")
                .to("{{service.endeca.location.dimension.rest}}")
                //.process(endecaFacetProcessor)
                .bean(EndecaResponseBuilder.class, "getEndecaResponseForLARFacets")
                .end()

Solution

  • It seems the issue wasn't because of the long URI but due to the fact that one of my header in the request was too large after i removed that header it started working