Spring Integration DSL:处理 FileSplitter START/END 标记负载 [英] Spring Integration DSL: Dealing with FileSplitter START/END marker payloads

查看:30
本文介绍了Spring Integration DSL:处理 FileSplitter START/END 标记负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置这样的集成流程:

I want to setup an integration flow like this:

    return IntegrationFlows
            .from("inputChannel")
            .split(fileSplitter)
            .handle(this::doStuff1)
            .handle(this::doStuff2)
            .handle(this::doStuff3)
            .aggregate()
            .handle(this::deleteFile)

文件拆分器:

@Bean
public FileSplitter fileSplitter() {
    FileSplitter fileSplitter = new FileSplitter(true, true);
    fileSplitter.setCharset(StandardCharsets.UTF_8);
    fileSplitter.setApplySequence(true);
    return fileSplitter;
}

输入是 File 类型.文件很大,所以我想逐行流式传输内容,处理它们并在最后删除文件.现在的问题是我必须检查并忽略整个链中所有处理程序方法中的文件 SOF,EOF 标记有效载荷.如果不检查每个 doStuff 方法中的类型,是否有不同的方法?(我认为建议可能有用,但还没有尝试过)

Input is of type File. The file size is big, so I want to stream the contents line by line, process them and delete the file at the end. The problem is now I have to check and ignore the file SOF,EOF marker payloads in all the handler methods along the chain. Is there a different way without checking the types in each doStuff methods? (I think advises will might be useful but haven't tried them yet)

推荐答案

您可以 .filter() 标记,.route() 将它们转移到不同的频道或.transform() 将它们转换为一个空字符串.

You can .filter() the markers, .route() them to a different channel or .transform() them to, say, an empty String.

.filter() 在您的情况下可能是最简单的,使用智能"过滤器也可以删除结束标记上的文件.

.filter() is probably the easiest in your case, with a "smart" filter that also deletes the file on the end marker.

这篇关于Spring Integration DSL:处理 FileSplitter START/END 标记负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆