java - 如何在 apache Camel (spring) 中测试路由

标签 java spring apache apache-camel

这是我的system.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>

这是我的 communications.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: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>

我有一个主要的

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

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

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

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

并且 Test 类有一个方法

    public Object test(Object info) {
//prints info
}

然而,当我运行时,没有任何打印。 。 。

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

我也在 Active MQ 中进行尝试,但没有成功收到错误

由于无法找到以下端点:brokerURL,请检查您的类路径是否包含所需的 Camel 组件 jar。

最佳答案

我使用 Active MQ 作为路由并且它有效

关于java - 如何在 apache Camel (spring) 中测试路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46659234/

相关文章:

java - 如何使用 JSR 验证来验证 Spring 中的 Controller 方法参数?

java - 循环读取 "ls/datadata"输出

spring - Maven 错误 - Spring Surf Alfresco

spring - 如何在 Spring Boot 休息服务方法中设置响应 header value ?

java - 将代码分离到 `src` 文件夹下的主分支和测试分支,而不更改包名称

java - 为每个线程生成一个新的对象实例是线程安全的操作吗?

java - 在 sqlite 上使用图像的更有效方法?

java - 如何做 "massive"作业调度( quartz ?)

django - myproject 的 wsgi.py 无法读取 settings.py

apache - 搞砸了 url 重写