使用 Spring DSL 的 Apache Camel
Apache Camel with Spring DSL
我正在尝试 运行 使用 spring DSL 在 Apache Camel 中创建一个简单的应用程序。
这是我的 spring-config.xml
<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>
这是我的 Java class 用于测试:
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();
}
}
}
我可以在我的控制台中看到 Hello 和 hello2,但我的文件没有被移动。我认为我在创建骆驼上下文时做错了什么。能否请你帮忙?我是否需要将路由显式添加到 camelContext?
得到解决方案。我应该在上下文开始后写 Thread.sleep() 。 Camel 上下文甚至在文件被拾取之前就停止了。
为了测试您的路线,您应该使用 http://camel.apache.org/testing.html 。这样你就不会陷入类似的问题。除此之外,camel-test 还提供了许多帮助程序,如断言、模拟、测试 camel 上下文。
骆驼测试 api 对某些开发人员来说可能很麻烦,这就是为什么我开始开发一个小型库,希望它可以解决一些样板 http://github.com/gmaslowski/camel-test-support
我正在尝试 运行 使用 spring DSL 在 Apache Camel 中创建一个简单的应用程序。 这是我的 spring-config.xml
<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>
这是我的 Java class 用于测试:
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();
}
}
}
我可以在我的控制台中看到 Hello 和 hello2,但我的文件没有被移动。我认为我在创建骆驼上下文时做错了什么。能否请你帮忙?我是否需要将路由显式添加到 camelContext?
得到解决方案。我应该在上下文开始后写 Thread.sleep() 。 Camel 上下文甚至在文件被拾取之前就停止了。
为了测试您的路线,您应该使用 http://camel.apache.org/testing.html 。这样你就不会陷入类似的问题。除此之外,camel-test 还提供了许多帮助程序,如断言、模拟、测试 camel 上下文。
骆驼测试 api 对某些开发人员来说可能很麻烦,这就是为什么我开始开发一个小型库,希望它可以解决一些样板 http://github.com/gmaslowski/camel-test-support