I am unable to read the file from a particular folder this is my code for routebuilder
@Component("RequestFileRouteBuilder")
public class RequestFileRouteBuilder extends RouteBuilder{
@Override
public void configure() throws Exception{
from("file:files/input")
.routeId("Myroute")
.process(Myprocessor);//processes the file input
}
}
Due to security violation I cannot share the entire pom.xml file which we are using in our project But I have included camel-file,camel-spring,camel-bean,camel-core.
the error which I am getting after running my application is as below
Caused by : org.apache.camel.NoSuchEndPointException : No endpoint cpould be found for : file://files/input, please check your classpath contains the needed Camel component jar.
I actually added camel-file dependency later after going through this site https://camel.apache.org/components/3.20.x/file-component.html
Where can I go wrong?
The piece of code seems to be working fine. Below is the code snippet which is working fine in my machine.
@Component("requestFileRouteBuilder")
public class RequestFileRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception{
from("file:C:/files/input/")
.routeId("RequestFileRouteId")
.process(exchange -> {log.info(exchange.getIn().getBody(String.class));});
}}
Below are the logs from application
2023-04-02 12:08:59.987 INFO 7192 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Started RequestFileRouteId (file://C:/files/input/)
2023-04-02 12:08:59.987 INFO 7192 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.14.0 (camel-1) started in 420ms (build:83ms init:313ms start:24ms)
2023-04-02 12:08:59.994 INFO 7192 --- [ main] com.example.Application : Started Application in 6.136 seconds (JVM running for 7.67)
2023-04-02 12:09:16.841 INFO 7192 --- [C:/files/input/] c.example.route.RequestFileRouteBuilder : Test Message
Below might be the issue that I can think of:
Are you passing full path to the input directory?
Have you included below dependencies in your pom xml?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>
Also, you need to check whether the spring boot version and camel version you are using are compatible with each other or not.