Apache camel 驼峰码头组件:使用可用选项

Apache camel 驼峰码头组件:使用可用选项,apache-camel,fuseesb,jbossfuse,Apache Camel,Fuseesb,Jbossfuse,我在我的路线中使用recipientList标记,如下所示。bean findCallbackUrl将返回一个字符串,它是我的目标地址。i、 e我将向该端点发出POST请求。例如,我可能有一台服务器正在侦听 因此,当findCallbackUrl bean返回的字符串(目的地)是jetty:,POST工作正常 但是,如果使用了中提到的一些选项,则会出现问题。当返回的目的地是jetty:或jetty:时,邮局工作正常。但是,如果返回的字符串是jetty:,则调用将成为GET请求 不知道这里发生

我在我的路线中使用recipientList标记,如下所示。bean findCallbackUrl将返回一个字符串,它是我的目标地址。i、 e我将向该端点发出POST请求。例如,我可能有一台服务器正在侦听


因此,当findCallbackUrl bean返回的字符串(目的地)是jetty:,POST工作正常

但是,如果使用了中提到的一些选项,则会出现问题。当返回的目的地是jetty:或jetty:时,邮局工作正常。但是,如果返回的字符串是jetty:,则调用将成为GET请求

不知道这里发生了什么。如果骆驼码头选项的使用方式与上面的不同,对于选项enableJmx或disableStreamCache或其他一些选项,生成的目标URL应该是GET请求


chunked=false可以用于生产者端点和消费者端点,还是仅用于消费者端点?

在jetty中选择http方法取决于camel交换的主体,或者取决于
CamelHttpMethod

查看类的源代码
org.apache.camel.component.http.helper.HttpHelper
,方法
createMethod

public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
    // compute what method to use either GET or POST
    HttpMethods answer;
    HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
    if (m != null) {
        // always use what end-user provides in a header
        answer = m;
    } else if (hasPayload) {
        // use POST if we have payload
        answer = HttpMethods.POST;
    } else {
        // fallback to GET
        answer = HttpMethods.GET;
    }

    return answer;
}
现在看看类
org.apache.camel.component.jetty.JettyHttProducer中该方法的调用:

HttpMethods methodouse=HttpHelper.createMethod(exchange,getEndpoint(),exchange.getIn().getBody()!=null)

我的选择不重要。在请求HTTP之前,请选中
exchange.getIn().getBody()
,或者您可以重置头
CamelHttpMethod

public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
    // compute what method to use either GET or POST
    HttpMethods answer;
    HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
    if (m != null) {
        // always use what end-user provides in a header
        answer = m;
    } else if (hasPayload) {
        // use POST if we have payload
        answer = HttpMethods.POST;
    } else {
        // fallback to GET
        answer = HttpMethods.GET;
    }

    return answer;
}