gpt4 book ai didi

apache-camel - Apache Camel - 使用 RouteBuilder 部署 war 应用程序

转载 作者:行者123 更新时间:2023-12-04 04:40:03 27 4
gpt4 key购买 nike

我是 Apache Camel 的新手,请让我知道我们如何部署自动激活 routeBulder 的 Camel war ?

我在 applicationContext.xml 中配置

    <camelContext xmlns="http://camel.apache.org/schema/spring" id="camel-3">
<routeBuilder ref="SearchProcessRoute" />
<bean id="SearchProcessRoute" class="camel.core.SearchProcessRouteBuilder" />

和路线 build 者
public class SearchProcessRouteBuilder extends RouteBuilder {

@Override
public void configure() throws Exception {
// TODO Auto-generated method stub
from("activemq://search.queue")
.log("Process from the queue")
.bean("SearchProcessBean","ProcessData")
.to("activemq://search.process.queue");
}}

当我向 search.queue 发送消息时,它不处理任何事情?

请让我知道使用 Camel 部署 Web 应用程序的正确方法(是否有示例应用程序)以及我们如何解决上述问题?

附注。我能够将它作为一个独立的应用程序来执行。但是,我想要实现的是从独立应用程序连接到在 war 中部署的 activmq(“activemq://search.queue”),然后在 war 中的路线(SearchProcessRouteBuilder)自动激活,并且将处理队列。然后它将消息发送到另一个队列“activemq://search.process.queue”。

Apache Camel 是否可以做到这一点,如果我们如何实现呢?

最佳答案

您只需要将以下内容添加到 web.xml 以引导 Spring/Camel 上下文

<!-- location of spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<!-- the listener that kick-starts Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

http://camel.apache.org/servlet-tomcat-example.html

关于apache-camel - Apache Camel - 使用 RouteBuilder 部署 war 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19022956/

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