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