0

I am trying to use Apache Camel File-Watch feature.

However I notice all example are used along with Spring.

Is there anyway to make use of this feature without Spring ?

Thank you for any potential input.

Best regards.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90

2 Answers2

1

Apache Camel is a standalone integration framework to easily integrate different systems using well know and established EIP (Enterprise Integration Patterns).

It is not tied to Spring in any way at its core and has different deployment / integration models out of which is Spring / Spring Boot for the sake of easing its adoption and configuration for Spring framework users.

Out of the runtime contexts, you can use for example Camel Main component to run your application having a File Watch component setup to watch the /tmp/ directory change events:

The main application would look like the following:

public class FileWatchApplication {

    private FileWatchApplication() {
    }

    public static void main(String[] args) throws Exception {
        // use Camels Main class
        Main main = new Main(FileWatchApplication.class);
        // now keep the application running until the JVM is terminated (ctrl + c or sigterm)
        main.run(args);
    }
}

A simple RouteBuilder setting up your File Watch component would look like the following (note that it must be within the same (or child) package of the FileWatchApplication class):

public class FileWatchRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        // snippet configuration from the official documentation
        from("file-watch:///tmp/")
                .log("File event: ${header.CamelFileEventType} occurred on file ${header.CamelFileName} at ${header.CamelFileLastModified}");
    }
}
tmarwen
  • 15,750
  • 5
  • 43
  • 62
-2

Camel is based on Spring. In fact, the Camel Context is an extension of the Spring Application Context. So if you have Camel, you also must have Spring.

Doug Grove
  • 962
  • 5
  • 5