Hello,

I'm developping a payment platform and I decided to use Camel EIP 2.18.0 as
my communication framework. In particular the Netty HTTP4 component. Note
that I'm new to Camel.

I have a problem using Netty HTTP4 while requesting a simple web service
published by the European Central Bank to get the last Euro <-> currency
exchange rates.
This service can be query with the following URL:
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml which returns a
simple xml file.

The route is configured as follow in my RouteBuilder class (I have added
traces to see what's going on):

        @Override public void configure() throws Exception { 
                
                from("direct:ecb").wireTap("log:TRACE?showAll=true").process(new
Processor(){
                        @Override public void process(Exchange exchange) throws 
Exception {
                                Message message = exchange.getOut();
                                message.setHeader(Exchange.HTTP_METHOD, 
HTTP_METHOD_GET);
                        }}).to(ECB_WEB_SERVICE).process(new Processor(){
                                @Override public void process(Exchange 
exchange) throws Exception {
                               String body = 
exchange.getIn().getBody(String.class);
                               log (Level.DEBUG, "Body: " + body);
                                }
                        }).end();

        }

And invoked like this (there is no body and no parameter for the requested
service, I did try with null and empty Object array):

                ProducerTemplate producer = 
getContext().createProducerTemplate();
                String responseBody = producer.requestBody("direct:ecb", new 
Object[0],
String.class);

When I run the service, I obtain this:

---------------------
2017-02-05 13:42:52.578 INFO  - [ECB Eurofxref] Invokes
netty4-http:http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml?traceEnabled=true

2017-02-05 13:42:52.584 DEBUG - Starting producer: Producer[direct://ecb]
2017-02-05 13:42:52.584 DEBUG - Adding to producer cache with key:
direct://ecb for producer: Producer[direct://ecb]
2017-02-05 13:42:52.589 DEBUG - >>>> direct://ecb Exchange[]
2017-02-05 13:42:52.597 INFO  - ID-SCO-ASUS-62929-1486298532114-0-2 >>>
(route12) from(direct://ecb) --> wireTap(log:TRACE?showAll=true) <<<
Pattern:InOut, Headers:{breadcrumbId=ID-SCO-ASUS-62929-1486298532114-0-1},
BodyType:Object[], Body:[Ljava.lang.Object;@16aeed18
2017-02-05 13:42:52.601 DEBUG - >>>> (wiretap) log:TRACE?showAll=true
Exchange[]
2017-02-05 13:42:52.601 INFO  - ID-SCO-ASUS-62929-1486298532114-0-2 >>>
(route12) wireTap(log:TRACE?showAll=true) --> Processor@0x7cf7aee <<<
Pattern:InOut, Headers:{breadcrumbId=ID-SCO-ASUS-62929-1486298532114-0-1},
BodyType:Object[], Body:[Ljava.lang.Object;@16aeed18
2017-02-05 13:42:52.601 DEBUG - Using ComponentResolver:
org.apache.camel.impl.DefaultComponentResolver@1827a871 to resolve component
with name: log
2017-02-05 13:42:52.601 INFO  - ID-SCO-ASUS-62929-1486298532114-0-2 >>>
(route12) Processor@0x7cf7aee -->
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml?traceEnabled=true
<<< Pattern:InOut, Headers:{CamelHttpMethod=GET}, BodyType:null, Body:[Body
is null]
2017-02-05 13:42:52.602 DEBUG - Lookup Component with name log in registry.
Found: null
2017-02-05 13:42:52.606 DEBUG - >>>>
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml?traceEnabled=true
Exchange[ID-SCO-ASUS-62929-1486298532114-0-2]
2017-02-05 13:42:52.607 DEBUG - Lookup Component with name log-component in
registry. Found: null
2017-02-05 13:42:52.609 DEBUG - Found component: log via type:
org.apache.camel.component.log.LogComponent via:
META-INF/services/org/apache/camel/component/log
2017-02-05 13:42:52.616 DEBUG - Registered MBean with ObjectName:
org.apache.camel:context=camel-1,type=components,name="log"
2017-02-05 13:42:52.617 DEBUG - Creating endpoint
uri=[log://TRACE?showAll=true], path=[TRACE]
2017-02-05 13:42:52.621 DEBUG - Configured property: showAll on bean:
org.apache.camel.processor.DefaultExchangeFormatter@727eece6 with value:
true
2017-02-05 13:42:52.621 DEBUG - log://TRACE?showAll=true converted to
endpoint: log://TRACE?showAll=true by component:
org.apache.camel.component.log.LogComponent@7e5c50c7
2017-02-05 13:42:52.623 DEBUG - Starting producer:
Producer[log://TRACE?showAll=true]
2017-02-05 13:42:52.624 DEBUG - Adding to producer cache with key:
log://TRACE?showAll=true for producer: Producer[log://TRACE?showAll=true]
2017-02-05 13:42:52.627 DEBUG - >>>> log://TRACE?showAll=true
Exchange[ID-SCO-ASUS-62929-1486298532114-0-3]
2017-02-05 13:42:52.636 INFO  - Exchange[Id:
ID-SCO-ASUS-62929-1486298532114-0-3, ExchangePattern: InOnly, Properties:
{CamelCorrelationId=ID-SCO-ASUS-62929-1486298532114-0-2,
CamelCreatedTimestamp=Sun Feb 05 13:42:52 CET 2017,
CamelMessageHistory=[DefaultMessageHistory[routeId=route12, node=wireTap7]],
CamelToEndpoint=log://TRACE?showAll=true}, Headers:
{breadcrumbId=ID-SCO-ASUS-62929-1486298532114-0-1}, BodyType: Object[],
Body: [Ljava.lang.Object;@16aeed18, Out: null: ]
2017-02-05 13:42:52.716 DEBUG - Created new TCP client bootstrap connecting
to www.ecb.europa.eu:80 with options: Bootstrap(BootstrapConfig(group:
NioEventLoopGroup, channelFactory: NioSocketChannel.class, options:
{SO_KEEPALIVE=true, TCP_NODELAY=true, SO_REUSEADDR=true,
CONNECT_TIMEOUT_MILLIS=10000}, handler:
org.apache.camel.component.netty4.http.HttpClientInitializerFactory@5d9ac1e2,
resolver: io.netty.resolver.DefaultAddressResolverGroup@638049c1))
2017-02-05 13:42:52.810 DEBUG - Creating connector to address:
www.ecb.europa.eu:80
2017-02-05 13:42:52.833 DEBUG - Channel: [id: 0x4cc24968,
L:/192.168.0.1:63371 - R:www.ecb.europa.eu/23.35.120.11:80] writing body:
DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1, content:
UnpooledUnsafeHeapByteBuf(ridx: 0, widx: 0, cap: 0))
GET
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml?traceEnabled=true
HTTP/1.1
host: www.ecb.europa.eu:-1
connection: keep-alive
2017-02-05 13:42:53.004 DEBUG - Http responseCode: 200
2017-02-05 13:42:53.005 INFO  - ID-SCO-ASUS-62929-1486298532114-0-2 >>>
(route12)
http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml?traceEnabled=true
--> Processor@0x6f330eb9 <<< Pattern:InOut, Headers:{Accept-Ranges=bytes,
CamelHttpResponseCode=200, CamelHttpResponseText=OK, Connection=keep-alive,
Content-Length=1624, Content-Type=text/xml, Date=Sun, 05 Feb 2017 12:42:52
GMT, ETag="658-547a177fe1400", Last-Modified=Fri, 03 Feb 2017 14:55:12 GMT,
Server=Apache,
Set-Cookie=cookie.ECB=!OpO059NiZuQAb+HViMJddZBG69fgZRZzD6T/guUaxnhUmr2gQXmRuF1US8My8Vw7i5YzRz4ZALA7PGw=;
path=/; Httponly}, BodyType:null, Body:[Body is null]
2017-02-05 13:42:53.007 DEBUG - [ECB Eurofxref] hasOut: false

2017-02-05 13:42:53.010 DEBUG - [ECB Eurofxref] Body: null

2017-02-05 13:42:53.012 DEBUG - Releasing Netty HttpResonse ByteBuf
2017-02-05 13:42:53.014 DEBUG - Stopping producer: Producer[direct://ecb]
ECB Response from request body: null

-----------------------

I see the GET query and http response OK, but the response body is (always)
null.
What I do not understand is why the body is null whereas the response trace
indicates Content-Length=1624.

Any help will be highly appreciated. I'm stuck on this problem and did not
find any response on Internet so far.

Many thanks in advance.

Stephane Coutant.




--
View this message in context: 
http://camel.465427.n5.nabble.com/Netty-Http4-client-Null-body-whereas-content-length-0-tp5793490.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to