spring 集成文件拆分器将文件标记作为负载发送
spring integration file splitter sending file markers as payload
我有 spring xd 源模块,它按 line.I 拆分文本文件行,想查看文件名并计算文件中的行数,因此我使用文件拆分器 filemarkers.But 问题是,如果我在文件中有一个记录,文件计数将作为有效负载出现,并且将有 3 行(1 条记录 +2 来自文件标记开始和结束)因此我的处理器期望有效负载作为文件记录得到一些filemarkers.How 我可以将它们设为 headers 并且不出现在负载中吗
<?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
FileSplitter.FileMarkerEND 消息将包含所需的行数。
不可能;我们可以消除开始标记,但问题是我们不知道在不进行下一次读取的情况下已经到达文件末尾(这是当我们到达 EOF 时发出结束标记)。
您可以添加 <filter/>
以跳过开始标记,但无法确定最后一条 "real" 消息确实是最后一条。
您可以添加一个转换器来将 END 标记转换为空字符串。
我想,我们可以向 FileSplitter
添加一个选项来预读,但它现在不这样做。
随意打开一个Improvement JIRA Issue。
您还可以创建自定义拆分器。
我有 spring xd 源模块,它按 line.I 拆分文本文件行,想查看文件名并计算文件中的行数,因此我使用文件拆分器 filemarkers.But 问题是,如果我在文件中有一个记录,文件计数将作为有效负载出现,并且将有 3 行(1 条记录 +2 来自文件标记开始和结束)因此我的处理器期望有效负载作为文件记录得到一些filemarkers.How 我可以将它们设为 headers 并且不出现在负载中吗
<?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
FileSplitter.FileMarkerEND 消息将包含所需的行数。
不可能;我们可以消除开始标记,但问题是我们不知道在不进行下一次读取的情况下已经到达文件末尾(这是当我们到达 EOF 时发出结束标记)。
您可以添加 <filter/>
以跳过开始标记,但无法确定最后一条 "real" 消息确实是最后一条。
您可以添加一个转换器来将 END 标记转换为空字符串。
我想,我们可以向 FileSplitter
添加一个选项来预读,但它现在不这样做。
随意打开一个Improvement JIRA Issue。
您还可以创建自定义拆分器。