Spring integration spring集成文件拆分器将文件标记作为有效负载发送

Spring integration spring集成文件拆分器将文件标记作为有效负载发送,spring-integration,spring-xd,Spring Integration,Spring Xd,我有一个spring xd源模块,它可以逐行分割文本文件。我想查看文件名并计算文件中的行数,因此我使用带有文件标记的文件拆分器。但问题是,如果我在文件中有一条记录,则文件计数将作为有效负载,3行将出现(1条记录+文件标记开始和结束的2条记录)因此,期望负载作为文件记录的处理器得到了一些文件标记。我如何使它们作为标题而不出现在负载中 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.spring

我有一个spring xd源模块,它可以逐行分割文本文件。我想查看文件名并计算文件中的行数,因此我使用带有文件标记的文件拆分器。但问题是,如果我在文件中有一条记录,则文件计数将作为有效负载,3行将出现(1条记录+文件标记开始和结束的2条记录)因此,期望负载作为文件记录的处理器得到了一些文件标记。我如何使它们作为标题而不出现在负载中

<?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:int="http://www.springframework.org/schema/integration"
           xmlns:int-aws="http://www.springframework.org/schema/integration/aws"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
            http://www.springframework.org/schema/integration/aws http://www.springframework.org/schema/integration/aws/spring-integration-aws-1.0.xsd">

        <int:poller fixed-delay="${fixed-delay}" default="true"/>

        <bean id="credentials" class="org.springframework.integration.aws.core.BasicAWSCredentials">
            <property name="accessKey" value="${accessKey}"/>
            <property name="secretKey" value="${secretKey}"/>
        </bean>

        <bean
                class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="location">
                <value>dms-aws-s3-nonprod.properties</value>
            </property>
        </bean>

        <bean id="clientConfiguration" class="com.amazonaws.ClientConfiguration">
            <property name="proxyHost" value="${proxyHost}"/>
            <property name="proxyPort" value="${proxyPort}"/>
            <property name="preemptiveBasicProxyAuth" value="false"/>
        </bean>
    <bean id="s3Operations" class="org.springframework.integration.aws.s3.core.CustomC1AmazonS3Operations">
        <constructor-arg index="0" ref="credentials"/>
        <constructor-arg index="1" ref="clientConfiguration"/>
        <property name="awsEndpoint" value="s3.amazonaws.com"/>
        <property name="temporaryDirectory" value="${temporaryDirectory}"/>
        <property name="awsSecurityKey"  value="${awsSecurityKey}"/>
    </bean>



    <!-- aws-endpoint="https://s3.amazonaws.com"  -->
    <int-aws:s3-inbound-channel-adapter aws-endpoint="s3.amazonaws.com"
                                        bucket="${bucket}"
                                        s3-operations="s3Operations"
                                        credentials-ref="credentials"
                                        file-name-wildcard="${file-name-wildcard}"
                                        remote-directory="${remote-directory}"
                                        channel="splitChannel"
                                        local-directory="${local-directory}"
                                        accept-sub-folders="false"
                                        delete-source-files="true"
                                        archive-bucket="${archive-bucket}"
                                        archive-directory="${archive-directory}">
    </int-aws:s3-inbound-channel-adapter>

    int-file:splitter input-channel="splitChannel" output-channel="output" markers="true"/>

    <int:channel id="output"/>

    xd-shell>stream create feedTest16 --definition "aws-s3-source |processor| log" --deploy

dms-aws-s3-1.2属性
int file:splitter input channel=“splitChannel”output channel=“output”markers=“true”/
xd shell>stream create feedTest16——定义“aws-s3-source | processor | log”——部署

filespliter.FileMarker结束消息将包含所需的行数。

这是不可能的;我们可以消除开始标记,但问题是我们不知道在没有进行下一次读取的情况下已经到达了文件的结尾(如果已经达到EOF,则在该时间发出结束标记)

您可以添加一个
来跳过开始标记,但无法确定最后一条“真实”消息确实是最后一条

您可以添加一个转换器,将结束标记转换为空字符串

我想,我们可以在
filespliter
中添加一个选项来预读,但现在不行

请随意打开一个


您还可以创建自定义拆分器。

我的用例是获取文件名。还有其他方法可以获取文件名吗?
filespliter
FileHeaders.FILENAME
头添加到每个发出的消息中,如果您的有效负载是
File
filePath
。因为
spring integration
4.1.6-这意味着XD 1.2.1或更高版本。因此,我将标记设置为false,并将文件名作为头