如何轮询目录以及目录中复制的任何XLSX文件,请致电REST API加载feed

发布于 2025-02-03 09:54:08 字数 49 浏览 2 评论 0原文

我有一个用例,我想对目录进行轮询。 我找不到自己的方式,请提出某种方法来做到这一点。

I have a use case, i want to poll a directory, if the any .*xlsx file get pasted in that directory, i want to call a post rest API that will load the data.
I'm not able to find the my way, please suggest some way to do this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

很快妥协 2025-02-10 09:54:08

我相信您正在寻找完全工作的样本,我怀疑这将是一个,因为您的业务任务可能与其他人所做的不一样。

尽管我们不介意您是否贡献了这样的样本: https:// github。 com/spring-projects/spring-integration-samples

  1. 因此,要构建逻辑,我们需要提供IntegrationFlow https://docs.spring.io/spring-integration/docs/current/current/referent/referent/referent/html/dsl.html.html#java-dsl-dsl-dsl-dsl 。< /p>

  2. 要从DIR读取文件,我们需要使用files.inboundadapter()与各自的轮询策略。

  3. 您可以对轮询文件内容进行一些转换(.transform())。

  4. 通过http.outboundgateway()

    致电休息服务

类似的事情:(

    @Bean
    public IntegrationFlow fileReadingFlow() {
        return IntegrationFlows
                .from(Files.inboundAdapter(new File("myDir"))
                                .patternFilter("*.xlsx"),
                        e -> e.poller(Pollers.fixedDelay(1000)))
                .transform(...)
                .handle(Http.outboundGateway("")
                        .expectedResponseType(String.class))
                .transform(...)
                .get();
    }

我不知道您的XSLT内容是什么以及如何调用其剩余服务

。 //github.com/spring-projects/spring-integration-samples/tree/main/main/applications/file-split-ftp“ rel =” nofollow noreferrer“> https://github.com/spring-proing-projects/spring-integration-integration-integration-integration-integration-integration-integration -samples/tree/main/applications/file-split-ftp

I believe that you are looking for fully working sample and I doubt that is going to be one since your business task might not be the same what other people are doing.

Although we won't mind if you contribute back such a sample: https://github.com/spring-projects/spring-integration-samples.

  1. So, to build a logic we need to provide an IntegrationFlow: https://docs.spring.io/spring-integration/docs/current/reference/html/dsl.html#java-dsl.

  2. To read files from a dir we need to use a Files.inboundAdapter() with respective polling policy.

  3. You may do some transformation (.transform()) about polled file content or so.

  4. Call the REST service via Http.outboundGateway()

  5. Do the post-process.

Something like this:

    @Bean
    public IntegrationFlow fileReadingFlow() {
        return IntegrationFlows
                .from(Files.inboundAdapter(new File("myDir"))
                                .patternFilter("*.xlsx"),
                        e -> e.poller(Pollers.fixedDelay(1000)))
                .transform(...)
                .handle(Http.outboundGateway("")
                        .expectedResponseType(String.class))
                .transform(...)
                .get();
    }

(Haven't checked as working since I don't know what is your XSLT content and how you call the REST service.)

This sample does something with files reading to gather some ideas: https://github.com/spring-projects/spring-integration-samples/tree/main/applications/file-split-ftp

攒眉千度 2025-02-10 09:54:08

我们有一个系统(几乎)相同(仅XML而不是XLSX),并且我们使用Apache Camel https:// https:// camel.apache.org/

春季启动的集成很好。您只需要从(“ file:////// path; path”).to(“ http:&lt; host&gt;:port/&lt; path;)您可能需要的

是要划到的代码线以进行过滤,并增加了一些转换,但这是一个不错的软件。

We have a system that does (almost) the same (just xml instead of xlsx) and we use Apache Camel https://camel.apache.org/

Integration is good with Spring Boot. You just need to define your route from("file:///<path").to("http:<host>:port/<path>) and it will do probably what you need.

Might need to tweek the line of code to get filtering and maybe add some transformation but it is a nice peace of software.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文