如何在Java dsl中配置cxf rsclient bean?

时间:2015-12-17 12:36:37

标签: java spring-boot apache-camel cxf

我想在Java dsl中定义cxf:rsclient而不是基于xml的dsl。 我在Java dsl中定义了以下内容。

for (i = 0; i < place_names.length; i++) {
  for (j = 0; j < data.rows.length; j++) {
    if (place_names[i].name === data.rows[j].name) {
      geom.push(data.rows[j].st_asgeojson);
      geom1.push({
        name: data.rows[j].name,
        geometry: data.rows[j].st_asgeojson
      });
      matched_average_value.push(place_names[i].average);
      matched_sum_value.push(place_names[i].sum);
      matched_minimum_value.push(place_names[i].minmum);
      matched_maximum_value.push(place_names[i].maximum);
    }
    else {
      console.log("no matches found");
    }
  }
}

我有以下RSClient

    from("direct:fromChannel")
        .split()
        .tokenizeXML("APIDataMessage").streaming()
        .unmarshal(jaxb)
        .convertBodyTo(com.testing.camel.MeasureEvent.class)
        .setHeader("Content-Type", constant("application/json"))
        .to("cxfrs://bean://toClient");

这是我的jsonProvider定义:

@Bean
public SpringJAXRSClientFactoryBean toClient()
{
    SpringJAXRSClientFactoryBean springJAXRSClientFactoryBean = new SpringJAXRSClientFactoryBean();
    String measurementEventURL = "http://" + connectorsConfig.getHost() + 
            ":" + connectorsConfig.getPort() + "/api/measurementEvents";

    springJAXRSClientFactoryBean.setBeanId("toClient");
    springJAXRSClientFactoryBean.setAddress(measurementEventURL);
    springJAXRSClientFactoryBean.setServiceClass(com.testing.camel.MeasurementEventEndpoint.class);
    springJAXRSClientFactoryBean.setLoggingFeatureEnabled(true);
    springJAXRSClientFactoryBean.setSkipFaultLogging(true);
    springJAXRSClientFactoryBean.setProvider(jsonProvider());
    return springJAXRSClientFactoryBean;
}

以下是我在调用此路线时看到的堆栈跟踪。

堆栈跟踪

JacksonJsonProvider jsonProvider()
{
    return new JacksonJsonProvider();
}

0 个答案:

没有答案