如何从骆驼的servlet组件路线HTTP组件? [英] How to route from Camel servlet component to http component?

查看:177
本文介绍了如何从骆驼的servlet组件路线HTTP组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想配置接收HTTP POST和它POST到服务的多个实例的组播路由。

I'm trying to configure a multicast route that receives an HTTP POST and POSTs it to multiple instances of a service.

从阅读文档,并与骆驼的例子,servlet的tomcat的发挥,它看起来像它应该是简单的,但我坚持。这个问题(http://stackoverflow.com/questions/5646557/apache-camel-http-to-http-routing-is-it-possible)是有用的,但我仍然坚持。

From reading the documentation, and playing with the camel-example-servlet-tomcat, it looks like it should be simple, but i'm stuck. This question (http://stackoverflow.com/questions/5646557/apache-camel-http-to-http-routing-is-it-possible) was helpful, but i'm still stuck.

下面是我的配置骆驼的Servlet的web.xml:

Here's my web.xml for configuring the Camel Servlet:

<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>

下面是我的骆驼背景和路径:

Here's my camel context and route:

<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工具(海报插件为火狐)两个端点的URI成功。

The service expects data in request parameters. i can post directly to both endpoint URIs with an http tool ("Poster" plugin for Firefox) successfully.

然而,当我发布这个Web应用程序(在码头上运行),在URI的http://本地主机:8080 /发送/许可证我得到一个404错误。在码头调试日志,我看到DEBUG [CamelHttpTransportServlet.service]:无消费
服务请求[POST /发送/许可证]

However, when i post to this webapp (running in Jetty), at the URI "http://localhost:8080/send/license" i get a 404 error. In the Jetty debug log, i see "DEBUG [CamelHttpTransportServlet.service]: No consumer to service request [POST /send/license]"

我试图简化路线是这样的:

I tried simplifying the route to look like this:

要简化路线,我放弃了组播成分,所以看起来
像这样的:

To simplify the route, i dropped the multicast component, so it looks like this:

<route id="myRoute" streamCache="true">
<from uri="servlet:///license"/>
<to uri="http://192.168.22.95:8135/transform-service/send/license"/>
</route>

但我得到了同样的错误。使用&LT;从URI =的servlet:///0.0.0.0:8080 /发送/许可证。/&GT; ,我得到了同样的错误。

but i get the same error. Using <from uri="servlet:///0.0.0.0:8080/send/license"/>, i get the same error.

我失去了一些东西明显在配置的URI骆驼的servlet?

Am i missing something obvious in configuring the URI for the Camel servlet?

推荐答案

如果你不为你的servlet作为CamelServlet使用默认名称,那么你需要参考该名称的端点URI,

If you do not use the default name for your servlet as CamelServlet, then you need to refer to that name in the endpoint uri,

<from uri="servlet:///license"/>

然后应该是

<from uri="servlet:///license?servletName=MulticastServlet"/>

这篇关于如何从骆驼的servlet组件路线HTTP组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆