Apache camel Apache Camel-使用RouteBuilder部署war应用程序
我是Apache Camel的新手,请告诉我如何使用Camel部署一场自动激活routeBulder的战争 我已在applicationContext.xml中进行了配置Apache camel Apache Camel-使用RouteBuilder部署war应用程序,apache-camel,Apache Camel,我是Apache Camel的新手,请告诉我如何使用Camel部署一场自动激活routeBulder的战争 我已在applicationContext.xml中进行了配置 <camelContext xmlns="http://camel.apache.org/schema/spring" id="camel-3"> <routeBuilder ref="SearchProcessRoute" /> 当我向search.queue发送消息时,它不会处理任何事情
<camelContext xmlns="http://camel.apache.org/schema/spring" id="camel-3">
<routeBuilder ref="SearchProcessRoute" />
当我向search.queue发送消息时,它不会处理任何事情
请让我知道使用camel部署web应用程序的正确方法(是否有任何示例应用程序)以及我们如何解决上述问题
另外,我可以作为一个独立的应用程序来执行。但是,我想要实现的是从独立应用程序连接到ActivVMQ(“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>
上下文配置位置
类路径:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
请参见我认为jetty server只侦听http请求,因此在活动mq队列的顶部,您必须编写一个http层代码,这也意味着servlet或其他内容。当我对此做了更多的研究时,发现您可以在没有spring的情况下执行同样的操作。看见从Camel 2.11Hi boday开始提供,请让我知道如何处理以下场景。我将Pojo对象发送到war中的队列,然后使用war,我需要从队列中读取并处理该对象。完成后,该对象将设置为另一个队列(已处理队列)。处理这种情况的最佳方法是什么?如果您只需要在队列和处理器之间发送数据,那么最干净的方法是为每个队列定义一个专用路由,并只在路由/队列之间发送数据…不确定您是否有其他要求
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");
}}
<!-- 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>