2016-03-30 16 views
1

ポーリング動的ダイナミック遅延設定

私はs3.The固定遅延からファイルをポーリングする統合からポーラー・コンポーネントを使用しています

は15分と最大メッセージレートが、これはダウンストリームにいた私は1つの【選択の理由です私はHTTPを使用して以来、xdのメッセージが詰まっていました。これは100kレコードファイルのファイルですが、ファイルサイズが小さいときは、私はfast.Nowを処理することができますが、まだ15分待っています動的にファイルのサイズ私たちはファイルのサイズに応じて、私たちはレコードの数を取得するか、固定遅延または固定レートを動的に変更することができますか?春の統合から開始

<int:poller fixed-delay="${fixedDelay}" default="true" max-messages-per-poll="${maxMessageRate}"> 
     <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}"/> 
</bean> 



<bean id="credentials" class="org.springframework.integration.aws.core.BasicAWSCredentials"> 
    <property name="accessKey" value="${accessKey}"/> 
    <property name="secretKey" value="${secretKey}"/> 
</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="${fileNameWildcard}" 
            remote-directory="${remoteDirectory}" 
            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 id="s3splitter" input-channel="splitChannel" output-channel="bridge" 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> 

答えて

1

4.2 AbstractMessageSourceAdviceintroducedされている:この方法は、受信()メソッドの後に呼び出され

。再度、ソースを再構成したり、結果に応じて何らかのアクションをとることができます(ソースによって作成されたメッセージがない場合はnullになる可能性があります)。別のメッセージを返すことさえできます!バージョン4.3以降で

我々はCompoundTriggerAdviceを紹介:http://docs.spring.io/spring-integration/docs/4.3.0.BUILD-SNAPSHOT/reference/html/messaging-channels-section.html#_compoundtriggeradviceあなたが​​サイズに基づいて、ユースケースのために使用することができます

+0

a.file 100 mb b.file 1 mbとc.file 10 mbと仮定します。私はポーラーがそれをランダムに引き出すと思いますか?a.fileには10分のファイルbの固定遅延があります。 c 5分 – constantlearner

+0

Mmm。それは問題ではありません。現在のメッセージの次のポーリング時間を変更したいとします。あなたは 'AbstractMessageSourceAdvice.afterReceive()' implで行うことができ、 'DynamicPeriodicTrigger'を使って、ファイルサイズに基づいて' period'を変更することができます。 –

+0

ありがとう – constantlearner

関連する問題