0

我的路线如下所示 -

@Override
    public void configure() throws Exception {

        from("kafka:adapterTopic")
        .to("rest://post:gatewayinbound-dev11.devsite.com");
    }

我也试过这个,

.to("rest:post:gatewayinbound-dev11.devsite.com");

还有这个,

restConfigutation().host("gatewayinbound-dev11.devsite.com");
from("kafka:adapterTopic")
.to("rest:post:provideStatus/");

我已经尝试过camel-rest-starter在类路径中使用依赖项,也没有尝试使用它。

我试过把camel-rest而不是camel-rest-starter放在pom中。

但是没有什么能让异常消失,下面是堆栈跟踪-

{"timestamp":"2020-04-21 18:17:45.327","severity":"ERROR","class":"org.springframework.boot.SpringApplication","crId":"","msg":"Application run failed","exception":"org.apache.camel.RuntimeCamelException","cause":"org.apache.camel.FailedToCreateRouteException: Failed to create route route10 at: >>> To[rest:post:gatewayinbound-dev11.devsite.com] <<< in route: Route(route10)[[From[kafka:adapterTopic]] -> [To[rest:... because of Failed to resolve endpoint: rest:\/\/post:gatewayinbound-dev11.devsite.com due to: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rest-configuration' defined in class path resource [org\/apache\/camel\/model\/rest\/springboot\/RestConfigurationDefinitionAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.camel.spi.RestConfiguration]: Factory method 'configureRestConfigurationDefinition' threw exception; nested exception is java.lang.IllegalArgumentException: Cannot configure option [useXForwardHeaders] with value [true] as the bean class [org.apache.camel.spi.RestConfiguration] has no suitable setter method, or not possible to lookup a bean with the id [true] in Spring Boot registry"

请在这里帮助我。查看 Camel 网站上的示例,配置休息生产者端点看起来很容易,但对我来说却非常困难。

编辑-

由于 Rest 组件是 camel-core 的一部分,我使用的是camel-core-2.22.1

然后按照 Raúl Cancino 的建议,我也尝试了这个-

to("rest:post:provideStatus?host=gatewayinbound-dev11.devsite.com:443")
4

2 回答 2

0

问题出在我的应用程序使用的骆驼核心库版本(作为传递依赖项),当我切换到骆驼核心2.24.2时,问题得到了解决。

我比较了骆驼核心 2.22.1 和 2.24.2 两个版本的 org.apache.camel.spi.RestConfiguration 类,发现旧版本中缺少属性useXForwardHeaders 。

于 2020-04-22T15:43:39.070 回答
0

请在您的 to() 上尝试以下 uri 格式,作为起点:

to("rest:post:provideStatus?host=gatewayinbound-dev11.devsite.com:443")

然后你可以切换到休息配置

restConfiguration().host("gatewayinbound-dev11.devsite.com:443");

此外,使用 camel-http 这将是:

.setHeader(Exchange.HTTP_METHOD,constant(org.apache.camel.component.http.HttpMethods.POST))
.to("https:gatewayinbound-dev11.devsite.com/provideStatus?bridgeEndpoint=true")

希望这对你有用

于 2020-04-22T10:30:47.307 回答