如何测试apache驼峰(春天)的路线

时间:2017-10-10 05:33:58

标签: java spring apache apache-camel

这是我的system.xml

<p>
  content before
</p>
<div class="c1">
  <div class="overlay"></div>
  <div class="c2">
    <h1>
      some content
    </h1>
    <p>
      some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content
      under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay
    </p>
    <p>
      some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay some content under overlay
    </p>
  </div>
</div>
<p>
  content after
</p>

这是我的communication.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amq="http://activemq.apache.org/schema/core"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
       http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <import resource="jetty.xml" />
    <import resource="communication.xml" />

    <camelContext xmlns="http://camel.apache.org/schema/spring"
        id="camel">
        <route> 
        <from uri="file://test.json"/>
            <threads>
                <bean ref="operationTest" method="test" />
            </threads>
        </route>
    </camelContext>
</beans>

我有一个主要的

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util.xsd">

    <bean id="operationTest" class="edu.test.Test">
    </bean>
</beans>

并且Test类有一个

的方法
    context = new SpringServerContext(new FileSystemXmlApplicationContext("conf/system.xml"));

    Runtime.getRuntime().addShutdownHook(new Thread(group, new Runnable() {

        @Override
        public void run() {
            stop();
        }

    }, shutdownThreadName));
    context.startup();

然而,当我跑步时,没有任何打印。 。 。

我们不能通过文件触发from标签吗?

我也在尝试使用Active MQ,并没有成功获得

错误

因为找不到端点:brokerURL,请检查您的类路径是否包含所需的Camel组件jar。

1 个答案:

答案 0 :(得分:0)

我使用Active MQ作为路线并且它起作用了