【发布时间】:2016-02-29 13:04:43
【问题描述】:
下面是一个简单的camel rest-dsl
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<restConfiguration bindingMode="auto" component="netty4-http" port="8080" host="localhost"/>
<rest path="/mycontext">
<get uri="/foo">
<to uri="direct:fooService"/>
</get>
</rest>
<route>
<from uri="direct:fooService"/>
<to uri="netty4-http:http://localhost:9773/services/foo"/>
</route>
</camelContext>
当我调用 curl localhost:8080/mycontext/foo 时,它总是返回 404,但有以下异常:
org.apache.camel.component.netty4.http.NettyHttpOperationFailedException: Netty HTTP operation failed invoking http://localhost:9773/services/foo with statusCode: 404
at org.apache.camel.component.netty4.http.NettyHttpHelper.populateNettyHttpOperationFailedException(NettyHttpHelper.java:160)
at org.apache.camel.component.netty4.http.NettyHttpProducer$NettyHttpProducerCallback.done(NettyHttpProducer.java:111)
at org.apache.camel.component.netty4.NettyProducer$NettyProducerCallback.done(NettyProducer.java:491)
at org.apache.camel.component.netty4.handlers.ClientChannelHandler.channelRead0(ClientChannelHandler.java:189)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
我抓包的时候发现请求行不正确
GET http://localhost:9773/services/foo HTTP/1.1
但是当我直接点击后端时,请求行是GET /services/foo HTTP/1.1
谁能帮我解决问题
【问题讨论】:
-
您可以尝试将 URI 设置为预先在
Exchange.HTTP_URI标头中调用,或者尝试将&bridgeEndpoint=true设置为属性。正如documented Camel 将在调用实际 URI 之前删除任何组件属性。不确定这是否能解决您的问题 -
不幸的是,问题仍然存在:(
标签: rest apache-camel