文件在处理前被删除

时间:2016-02-27 03:27:19

标签: spring-integration spring-xd

我有带有兔子传输的spring xd模块,它从s3中提取文件并逐行拆分并在处理后删除它(ExpressionAdvice)。我的文件中有大约100万条消息(行)在s3中。文件获取下载到xd容器盒,我检查了md5sum和它相同,并有相同的行。我看到只有26万条奇怪的消息进入输出通道即处理器。我正在丢失大约740条消息。有时它随机一旦我看到我的输出通道中的所有消息,如100万,有时只有250k。我正在使用我的流的计数器测量这个。文件被下载,但我觉得它在10秒内处理所有记录/行之前被删除,我的文件大小约为700Mb。如果表达建议在处理之前删除,请告诉我。

 module.aws-s3-source.count=1 and module.aws-s3-source.concurrency=70
    stream1 as-s3-source |processor|sink

<?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:context="http://www.springframework.org/schema/context"
       xmlns:int-aws="http://www.springframework.org/schema/integration/aws"
       xmlns:int-file="http://www.springframework.org/schema/integration/file"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/integration/file
         http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
             http://www.springframework.org/schema/context
             http://www.springframework.org/schema/context/spring-context.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">


    <context:property-placeholder location="classpath*:test-${region}.properties" />

    <int:poller fixed-delay="${fixedDelay}" default="true">
        <int:advice-chain>
            <ref bean="pollAdvise"/>

        </int:advice-chain>
    </int:poller>


    <bean id="pollAdvise" class="org.springframework.integration.scheduling.PollSkipAdvice">
        <constructor-arg ref="healthCheckStrategy"/>

    </bean>



    <bean id="healthCheckStrategy" class="test.ServiceHealthCheckPollSkipStrategy">
        <property name="url" value="${url}"/>
        <property name="doHealthCheck" value="${doHealthCheck}"/>
        <property name="restTemplate" ref="restTemplate"/>

    </bean>

    <bean id="restTemplate"
          class="org.springframework.web.client.RestTemplate">
        <constructor-arg ref="requestFactory"/>

    </bean>


    <bean id="requestFactory"
          class="test.BatchClientHttpRequestFactory">
        <constructor-arg ref="verifier"/>

    </bean>

    <bean id="verifier"
          class="test.NullHostnameVerifier">

    </bean>


    <bean id="encryptedDatum" class="test.EncryptedSecuredDatum"/>




    <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="test.CustomC1AmazonS3Operations">

        <constructor-arg index="0" ref="clientConfiguration"/>
        <property name="awsEndpoint" value="s3.amazonaws.com"/>
        <property name="temporaryDirectory" value="${temporaryDirectory}"/>
        <property name="awsSecurityKey"  value=""/>
    </bean>


    <bean id="credentials" class="org.springframework.integration.aws.core.BasicAWSCredentials">

    </bean>

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

    <int-file:splitter input-channel="splitChannel" output-channel="output" markers="false" charset="UTF-8">

        <int-file:request-handler-advice-chain>
            <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
                <property name="onSuccessExpression" value="payload.delete()"/>
            </bean>
        </int-file:request-handler-advice-chain>

    </int-file:splitter>

    <int:channel-interceptor pattern="*" order="3">
        <bean class="org.springframework.integration.channel.interceptor.WireTap">
            <constructor-arg ref="loggingChannel" />
        </bean>
    </int:channel-interceptor>
    <int:logging-channel-adapter id="loggingChannel" log-full-message="true" level="INFO"/>

    <int:channel id="output"/>

</beans>

更新2:

我的信息流如下 AWS-S3-源|处理器| HTTP客户端|处理器&GT;队列:testQueue

1)现在我将流分割如下:

 aws-s3-source> queue:s3Queue

我能够非常快速地阅读我的所有100万条消息。 2)现在我又添加了一个流,如下所示我再次看到问题是s3停止拉文件并且每次都丢失消息

 queue:s3Queue>processor|http-client| processor> queue:testQueue 
3)观察是当我添加http-client时,这个问题再次发生,即。输入源中的某些消息丢失了。

4)现在我将文件拆分为125 Mb 5文件而不是660mb一个文件.ie 200 k记录5个文件。我没有看到问题我收到所有消息

我还看到很多消息在http-client之前在队列中堵塞。 我在想是否与xd内部的内存或线程有关?

1 个答案:

答案 0 :(得分:2)

  

如果在处理之前删除了表达建议,请告诉我。

没有;建议是围绕消息处理程序的around建议;它不能执行(计算表达式),直到分离器发出所有行。

文件是否可以在完全写入之前从s3中提取?

要调试此问题,我建议更改建议以将文件发送到另一个子流并在删除之前进行一些分析/记录。