由于olingo端点缺少属性,骆驼无法创建路由

时间:2018-11-21 10:25:31

标签: spring-boot apache-camel olingo

我正在尝试建立一个非常简单的方法来测试camel-olingo2组件。 在启动过程中,我可以验证我的Olingo2Component是否已使用正确的serviceUri填充,并且还添加到camelContext中。 目前,我正在针对公共OData测试站点进行测试,并且可以验证数据是否存在

以下是将Olingo成分添加到骆驼中的方法

@Bean
public Olingo2Component olingo2Component() {

    Olingo2Configuration olingo2Configuration = new Olingo2Configuration();
    olingo2Configuration.setServiceUri("https://services.odata.org/TripPinRESTierService");

    Olingo2Component olingo2Component = new Olingo2Component();
    olingo2Component.setConfiguration(olingo2Configuration);

    CamelContext camelContext = new DefaultCamelContext();
    camelContext.addComponent("olingo2", olingo2Component);

    return olingo2Component;
}

我的路线看起来像这样

<routes xmlns="http://camel.apache.org/schema/spring">
    <route id="test" autoStartup="true">
        <from uri="olingo2Component://read/People"/>
        <log message="${body}" />
    </route>
</routes>

我不知道真正缺少哪些属性。由于没有添加查询,我希望收到一个包含People的OData条目的json

任何帮助或提示将不胜感激

下面的完整堆栈跟踪

2018-11-21 11:01:46,123 o.s.b.SpringApplication ERROR - Application run failed(858)
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route test: Route(test)[[From[olingo2Component://read/People]] -> [Log[$... because of Missing properties for /read, need one or more from [endpointHttpHeaders, responseHandler, queryParams, edm]
	at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830)
	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136)
	at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:174)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:398)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:355)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
	at se.tradechannel.suitability.SuitabilityApplication.main(SuitabilityApplication.java:15)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route test: Route(test)[[From[olingo2Component://read/People]] -> [Log[$... because of Missing properties for /read, need one or more from [endpointHttpHeaders, responseHandler, queryParams, edm]
	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:147)
	at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3949)
	at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3856)
	at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3642)
	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3494)
	at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209)
	at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3253)
	at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3249)
	at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3272)
	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3249)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3165)
	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133)
	... 14 common frames omitted
Caused by: java.lang.IllegalArgumentException: Missing properties for /read, need one or more from [endpointHttpHeaders, responseHandler, queryParams, edm]
	at org.apache.camel.util.component.ApiConsumerHelper.findMethod(ApiConsumerHelper.java:61)
	at org.apache.camel.util.component.AbstractApiConsumer.<init>(AbstractApiConsumer.java:52)
	at org.apache.camel.component.olingo2.Olingo2Consumer.<init>(Olingo2Consumer.java:37)
	at org.apache.camel.component.olingo2.Olingo2Endpoint.createConsumer(Olingo2Endpoint.java:92)
	at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:69)
	at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:107)
	at org.apache.camel.impl.RouteService.doWarmUp(RouteService.java:172)
	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:145)
	... 26 common frames omitted
2018-11-21 11:01:46,128 s.t.s.SuitabilityApplication ERROR - org.apache.camel.FailedToCreateRouteException: Failed to create route test: Route(test)[[From[olingo2Component://read/People]] -> [Log[$... because of Missing properties for /read, need one or more from [endpointHttpHeaders, responseHandler, queryParams, edm](19)
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route test: Route(test)[[From[olingo2Component://read/People]] -> [Log[$... because of Missing properties for /read, need one or more from [endpointHttpHeaders, responseHandler, queryParams, edm]
	at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830)
	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:136)
	at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:174)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:398)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:355)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
	at se.tradechannel.suitability.SuitabilityApplication.main(SuitabilityApplication.java:15)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route test: Route(test)[[From[olingo2Component://read/People]] -> [Log[$... because of Missing properties for /read, need one or more from [endpointHttpHeaders, responseHandler, queryParams, edm]
	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:147)
	at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3949)
	at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3856)
	at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3642)
	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3494)
	at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:209)
	at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3253)
	at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3249)
	at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3272)
	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3249)
	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3165)
	at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133)
	... 14 common frames omitted
Caused by: java.lang.IllegalArgumentException: Missing properties for /read, need one or more from [endpointHttpHeaders, responseHandler, queryParams, edm]
	at org.apache.camel.util.component.ApiConsumerHelper.findMethod(ApiConsumerHelper.java:61)
	at org.apache.camel.util.component.AbstractApiConsumer.<init>(AbstractApiConsumer.java:52)
	at org.apache.camel.component.olingo2.Olingo2Consumer.<init>(Olingo2Consumer.java:37)
	at org.apache.camel.component.olingo2.Olingo2Endpoint.createConsumer(Olingo2Endpoint.java:92)
	at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:69)
	at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:107)
	at org.apache.camel.impl.RouteService.doWarmUp(RouteService.java:172)
	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:145)
	... 26 common frames omitted

1 个答案:

答案 0 :(得分:0)

我注意到应该自动添加edm(实体数据模型)属性。 camel-olingo最初使用$ metadata进行了调用以查找得到edm。其他属性也应该自动添加。当您将初始端点作为olingo端点时,这似乎不起作用。尽管文档说是这样。

您可以尝试

<routes xmlns="http://camel.apache.org/schema/spring">
    <route id="test" autoStartup="true">
        <from uri="timer://olingo.test?repeatCount=1&delay=-1"/>
        <to uri="olingo2Component://read/People"/>
        <log message="${body}" />
    </route>
</routes>

这将为您提供“内部服务器错误”异常,因为https://services.odata.org/TripPinRESTierService使用odata v4。

更改为camel-olingo4组件以使其返回数据。