Hello World with Camel 3.4 + Spring boot 2
Hello World with Camel 3.4 + Spring boot 2
我设置了一个基本应用程序,使用 Spring boot 2 和 Camel 3.4。下面的路由定义按预期工作:当应用程序启动时,每秒打印一条消息。
String endPoint = "timer://timerName?period=1000";
from(endPoint)
.routeId("helloStart")
.process(exchange -> out.println("Hello world"))
.end();
但是当我将端点更改为使用直接或文件组件时,路由不再有效,不再打印“hello world”。据我了解,这不是预期的行为。
String endPoint = "direct:helloStart";
// LOG: Route: helloStart started and consuming from: direct://helloStart
String endPoint = "file://src/main/resources/sample.xml";
// LOG: Route: helloStart started and consuming from: file://src/main/resources/xml/sample.xml
我使用camel-spring-boot-dependencies BOM,camel-spring-boot-starter(新的),camel-file|seda|direct...
有什么想法吗?
完全正常。你需要生产一些东西给直接点,否则不会有任何交换。使用计时器端点,每 1000 毫秒将创建一次交换,并在触发事件时传递到下一个端点。
对于文件端点,您需要查看文档:https://camel.apache.org/components/latest/file-component.html
端点的正确形式是:file:directoryName[?options]
因此您需要指定要轮询的文件夹,然后指定选项,例如 fileName 可以是 sample.xml
我设置了一个基本应用程序,使用 Spring boot 2 和 Camel 3.4。下面的路由定义按预期工作:当应用程序启动时,每秒打印一条消息。
String endPoint = "timer://timerName?period=1000";
from(endPoint)
.routeId("helloStart")
.process(exchange -> out.println("Hello world"))
.end();
但是当我将端点更改为使用直接或文件组件时,路由不再有效,不再打印“hello world”。据我了解,这不是预期的行为。
String endPoint = "direct:helloStart";
// LOG: Route: helloStart started and consuming from: direct://helloStart
String endPoint = "file://src/main/resources/sample.xml";
// LOG: Route: helloStart started and consuming from: file://src/main/resources/xml/sample.xml
我使用camel-spring-boot-dependencies BOM,camel-spring-boot-starter(新的),camel-file|seda|direct...
有什么想法吗?
完全正常。你需要生产一些东西给直接点,否则不会有任何交换。使用计时器端点,每 1000 毫秒将创建一次交换,并在触发事件时传递到下一个端点。
对于文件端点,您需要查看文档:https://camel.apache.org/components/latest/file-component.html
端点的正确形式是:file:directoryName[?options]
因此您需要指定要轮询的文件夹,然后指定选项,例如 fileName 可以是 sample.xml