Apache camel ApacheCamel与SpringDSL
我正在尝试使用SpringDSL在ApacheCamel中运行一个简单的应用程序。 这是我的spring-config.xmlApache camel ApacheCamel与SpringDSL,apache-camel,Apache Camel,我正在尝试使用SpringDSL在ApacheCamel中运行一个简单的应用程序。 这是我的spring-config.xml <bean id="jms" class="org.apache.camel.component.jms.JmsComponent"> <property name="connectionFactory"> <bean class="org.apache.activemq.ActiveMQConnectionFact
<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://localhost" />
</bean>
</property>
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file:src/data?noop=true" />
<process ref="downloadLogger" />
<to uri="jms:incomingOrders" />
</route>
</camelContext>
<bean id="downloadLogger" class="com.test.eip.camel.DownloadLogger"></bean>
}
我可以在控制台中看到Hello和hello2,但我的文件没有被移动。我认为我在创建骆驼上下文时做错了什么。你能帮忙吗?是否需要将路由显式添加到camelContext?获得了解决方案。我应该在上下文启动后编写Thread.sleep()。驼峰上下文甚至在提取文件之前就停止了。为了测试您应该使用的路由。这样你就不会陷入类似的问题。除此之外,camel测试还提供了许多助手,如断言、模拟、测试camel上下文 骆驼测试api对一些开发人员来说可能很麻烦,这就是为什么我开始开发一个小型库,希望它能够解决一些样板文件
public class CamelSpringTest {
public static void main(String[] args) throws Exception {
ApplicationContext appContext = new ClassPathXmlApplicationContext("spring-config.xml");
CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);
try {
System.out.println("Hello");
camelContext.start();
} finally {
System.out.println("Hello2");
camelContext.stop();
}
}