gpt4 book ai didi

apache-camel - Apache Camel 使用来自的 HTTP 定义路由

转载 作者:行者123 更新时间:2023-12-02 05:08:30 27 4
gpt4 key购买 nike

如何为“from”端点定义带有 HTTP 的 Camel Route?

我的目标是定义一个路由,当有 HTTP 请求时,消息将在 ActiveMQ 队列中排队。

我尝试了以下路由定义:

<route>
<from uri="http://localhost:8181/cxf/crm/customerservice/customers" />
<to uri="activemq:queue:LOG.ME" />
</route>

我从浏览器访问 URL:

http://localhost:8181/cxf/crm/customerservice/customers/123

我已验证 HTTP 请求已到达 Web 服务“customerservice”,因为我收到了来自该 Web 服务的 XML 响应。但是,没有消息在 ActiveMQ 队列中排队。

下面是处理来自 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”方法没有被执行。

如何为“from”端点定义带有 HTTP 的 Camel Route?

谢谢。

最佳答案

如果你想监听 HTTP 请求,那么你需要使用 servlet如果您在 Web 应用程序或 jetty 中运行组件嵌入一​​个简单的 http 服务器的组件。

两者都有很好的文档和示例。

http 和 http4 组件仅供生产者使用 ( <to ... /> )。

关于apache-camel - Apache Camel 使用来自的 HTTP 定义路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15877346/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com