Apache camel Apache Camel使用来自的HTTP定义路由
如何使用HTTP为“from”端点定义驼峰路由 我的目标是定义一个路由,当有HTTP请求时,消息将在ActiveMQ队列中排队Apache camel Apache Camel使用来自的HTTP定义路由,apache-camel,Apache Camel,如何使用HTTP为“from”端点定义驼峰路由 我的目标是定义一个路由,当有HTTP请求时,消息将在ActiveMQ队列中排队 <route> <from uri="activemq:queue:LOG.ME" /> <multicast> <pipeline> <bean ref="processor1" method="handle" /> <to uri="mock:result" /
<route>
<from uri="activemq:queue:LOG.ME" />
<multicast>
<pipeline>
<bean ref="processor1" method="handle" />
<to uri="mock:result" />
</pipeline>
<pipeline>
<bean ref="processor2" method="handle" />
<to uri="mock:result" />
</pipeline>
</multicast>
</route>
我尝试了以下路线定义:
<route>
<from uri="http://localhost:8181/cxf/crm/customerservice/customers" />
<to uri="activemq:queue:LOG.ME" />
</route>
我已经验证了HTTP请求已经到达web服务“customerservice”,因为我收到了来自web服务的XML响应。但是,ActiveMQ队列上没有消息排队
<route>
<from uri="activemq:queue:LOG.ME" />
<multicast>
<pipeline>
<bean ref="processor1" method="handle" />
<to uri="mock:result" />
</pipeline>
<pipeline>
<bean ref="processor2" method="handle" />
<to uri="mock:result" />
</pipeline>
</multicast>
</route>
下面是处理来自ActiveMQ队列的消息的路由定义
<route>
<from uri="activemq:queue:LOG.ME" />
<multicast>
<pipeline>
<bean ref="processor1" method="handle" />
<to uri="mock:result" />
</pipeline>
<pipeline>
<bean ref="processor2" method="handle" />
<to uri="mock:result" />
</pipeline>
</multicast>
</route>
我验证了ActiveMQ没有排队,因为我的bean“processor1”和“processor2”的“handle”方法没有执行
如何使用HTTP为“from”端点定义驼峰路由
谢谢。如果要侦听HTTP请求,则需要在web应用程序内部运行该组件,或者使用嵌入简单HTTP服务器的组件 两者都有很好的文档和例子
http和http4组件仅供生产者使用(
)。要侦听传入的http请求,可以使用jetty或cxf组件设置代理,然后该组件将调用web服务并将消息记录到activemq
比如说,
from("jetty:http://localhost:8282/xxx").
to("http://localhost:8181/cxf/crm/customerservice/customers").
to("activemq:queue:LOG.ME");
现在,要访问web服务,可以调用代理作为
http://localhost:8282/xxx
,而不是直接调用web服务。也可以使用cxf组件设置代理,这一点有很好的文档记录。这样做时,Web服务没有正确启动。在ServiceMix的控制台中,我发现显示“捆绑cxf jaxws blueprint正在等待依赖项[(&(component=jetty)(objectClass=org.apache.camel.spi.ComponentResolver))”,我已经在pom.xml中添加了必要的依赖项,“camel jetty”通过groupId org.apache.camel和相应的版本2.10.3I,我修改了示例ServiceMix项目“cxf jaxws蓝图”。在我的blueprint.xml上,我添加了localhost:8282/xxx“/>项“Bundle-cxf-jaxws-blueprint正在等待依赖项[(&(component=jetty)(objectClass=org.apache.camel.spi.ComponentResolver))]“在我在ServiceMix控制台上发出命令时已解决,功能:安装camel jetty项目中的camel jetty不可用于容器。如果您使用的是osgi容器,则所需的包需要是已部署的捆绑包的一部分,或者也需要部署捆绑包,在本例中为camel jetty捆绑包。谢谢。我现在正在探索如何使用ServiceMix的Jetty组件。组件上还有一些OSGi示例/文档,可以在karaf/SMX中运行。