0
votes

I set up a basic application, using Spring boot 2 and Camel 3.4. The route definition below is working as expected: when the application start, a message is printed every second.

String endPoint = "timer://timerName?period=1000";
from(endPoint)
    .routeId("helloStart")
    .process(exchange -> out.println("Hello world"))
    .end();

But when I change the endPoint to use the direct or file component, the route is not working anymore, there is no more "hello world" printed. From what I read, this is not the expected behaviour.

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

I use camel-spring-boot-dependencies BOM, camel-spring-boot-starter (the new one), camel-file|seda|direct...

Any idea ?

1

1 Answers

1
votes

It's completely normal. You need to produce something to the direct enpoint, otherwise there won't be any exchange. With the timer endpoint, every 1000ms an exchange will be created and will be passed to the next endpoint as the event will be fired.

For the file endpoint, you need to have a look at the documentation: https://camel.apache.org/components/latest/file-component.html

The correct form of the endpoint is: file:directoryName[?options]

So you need to specify a folder to be polled and after that specifying the option, like for example fileName which could be sample.xml