繁体   English   中英

Apache Camel File-Watch 没有 Spring

[英]Apache Camel File-Watch Without Spring

我正在尝试使用 Apache Camel File-Watch 功能。

但是我注意到所有示例都与 Spring 一起使用。

无论如何在没有 Spring 的情况下使用此功能?

感谢您提供任何潜在的意见。

此致。

Apache Camel是一个独立的集成框架,可以使用众所周知且已建立的 EIP(企业集成模式)轻松集成不同的系统。

它的核心不以任何方式与Spring绑定,并且具有不同的部署/集成模型,其中Spring / Spring Boot是为了简化Spring框架用户的采用和配置。

在运行时上下文之外,您可以使用例如Camel Main组件来运行具有File Watch组件设置的应用程序,以观察/tmp/目录更改事件:

主应用程序如下所示:

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);
    }
}

设置File Watch组件的简单RouteBuilder如下所示(请注意,它必须位于FileWatchApplication类的同一(或子)包中):

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}");
    }
}

Camel 是基于 Spring 的。 实际上,Camel Context 是 Spring Application Context 的扩展。 所以如果你有骆驼,你也必须有春天。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM