【发布时间】:2011-10-19 17:44:46
【问题描述】:
我正在尝试配置接收 HTTP POST 并将其 POST 到服务的多个实例的多播路由。
从阅读文档并使用 camel-example-servlet-tomcat 开始,它看起来应该很简单,但我被卡住了。这个question 很有帮助,但我还是卡住了。
这是我用于配置 Camel Servlet 的 web.xml:
<web-app...>
<!-- location of spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<!-- Camel servlet -->
<servlet>
<servlet-name>MulticastServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Camel servlet mapping -->
<servlet-mapping>
<servlet-name>MulticastServlet</servlet-name>
<url-pattern>/send/*</url-pattern>
</servlet-mapping>
<!-- the listener that kick-starts Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
<welcome-file>WEB-INF/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
这是我的骆驼背景和路线:
<camelContext trace="true" id="multicastCtx"
xmlns="http://camel.apache.org/schema/spring">
<route id="multicastRoute">
<from uri="servlet:///license"/>
<multicast stopOnException="false">
<to uri="http://192.168.22.95:8135/transform-service/send/license"/>
<to uri="http://10.50.1.58:9080/send/license"/>
</multicast>
</route>
</camelContext>
服务需要请求参数中的数据。我可以使用 http 工具(Firefox 的“海报”插件)成功地直接发布到两个端点 URI。
但是,当我发布到此 web 应用程序(在 Jetty 中运行)时,在 URI“http://localhost:8080/send/license”处我收到 404 错误。在 Jetty 调试日志中,我看到“DEBUG [CamelHttpTransportServlet.service]: No consumer 服务请求 [POST /send/license]"
我尝试将路线简化为如下所示:
为了简化路由,我删除了多播组件,所以看起来 像这样:
<route id="myRoute" streamCache="true">
<from uri="servlet:///license"/>
<to uri="http://192.168.22.95:8135/transform-service/send/license"/>
</route>
但我得到同样的错误。使用<from uri="servlet:///0.0.0.0:8080/send/license"/>,我得到同样的错误。
在为 Camel servlet 配置 URI 时我是否遗漏了一些明显的东西?
【问题讨论】:
标签: apache-camel