繁体   English   中英

使用camel-netty4-http的JBoss Fuse camel dsl-如何获取REST返回码以进行记录?

[英]JBoss Fuse camel dsl using camel-netty4-http - how to I obtain the REST return code in order to log it?

题:

我正在使用JBoss Fuse和camel-netty4-http发布到REST服务。
-如何获取REST返回码-又名“状态码”-(以便进行记录)?

样例代码:

@Override
public void configure() throws Exception {

... 

from("wmq:queue:mylocalqueue")
    .log("inMessage=" + (null==body()?"":body().toString()))
    .to("seda:node1?concurrentConsumers=20");

from("seda:node1")
    .streamCaching()
    .threads(20)
    .setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.POST))
    .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
    .toD("netty4-http:http://localhost:7001/MyService/myServiceThing?textline\\=true")
    .log("the http return/status code is [what?]...";  <=== need response/http code!!!    
}           

您的响应代码应位于您的Exchange标头中。 您可以使用一个简单的表达式来提取它。 像这样:

from("direct:start")
    .setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
    .setHeader(Exchange.CONTENT_TYPE, constant("application/json"))
    .to("netty4-http:http://localhost:8080")
    .log("The response code is: ${header["+Exchange.HTTP_RESPONSE_CODE+"]}");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM