2016-05-10 5 views
1

ファイル用のサードパーティのSFTPサーバーをポーリングする既存のSpring Integrationアプリケーションをメンテナンスしています。リモートエンドで一時的な問題が発生していると思われるパーミッションまたは「見つからない」エラーが発生することがあります。おそらく問題を解決するので、私はこれらのエラーを取得するアプリケーションを再試行したいと思います。 (私はまた、 "この問題をカバーする必要がある"問題を再試行するための要件が​​あります)。SFTPの再試行許可エラー

org.springframework.messaging.MessagingException: Problem occurred while synchronizing remote to local directory; nested exception is org.springframework.messaging.MessagingException: Failure occurred while copying from remote to local directory; nested exception is org.springframework.core.NestedIOException: failed to read file mypath/myfile.csv; nested exception is 3: Permission denied 
at [snip] 
Caused by: org.springframework.messaging.MessagingException: Failure occurred while copying from remote to local directory; nested exception is org.springframework.core.NestedIOException: failed to read file mypath/myfile.csv; nested exception is 3: Permission denied 
at [snip] 
Caused by: 3: Permission denied 
at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2846) [snip] 

大規模なグーグルとサークルでのラウンドの後、私はまだSpring Integrationでこれを行う方法を理解することができません。ここでは、既存の設定です:

<bean id="myAcceptOnceFilter" class="org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter"> 
    <constructor-arg index="0" ref="myLocalFileStore"/> 
    <constructor-arg index="1" name="prefix" value="myprefix_"/> 
    <property name="flushOnUpdate" value="true"/> 
</bean> 

<bean id="myCompositeFilter" class="org.springframework.integration.file.filters.CompositeFileListFilter"> 
    <constructor-arg> 
     <list> 
      <bean class="org.springframework.integration.sftp.filters.SftpSimplePatternFileListFilter"> 
       <constructor-arg value="myprefix" /> 
      </bean> 
      <ref bean="myAcceptOnceFilter"/> 
     </list> 
    </constructor-arg> 
</bean> 

<int-sftp:inbound-channel-adapter id="myInboundChannel" 
      session-factory="mySftpSessionFactory" 
      channel="myDownstreamChannel" 
      remote-directory="blah" 
      filter="myCompositeFilter" 
      local-directory="blah" 
      auto-create-local-directory="true" 
      > 
    <int:poller fixed-rate="10000" max-messages-per-poll="-1"> 
     <int:transactional transaction-manager="transactionManager" synchronization-factory="syncFactory" /> 
    </int:poller> 
</int-sftp:inbound-channel-adapter> 

編集:私はこの問題はmyCompositeFilterにあると思います。例外がスローされたときにmyAcceptOnceFilterの内部でrollback()が呼び出されているように見えません。コンポジットなしで単にmyAcceptOnceFilterを使用すると、コードは意図したとおりに機能します(つまり、rollback()が呼び出されます)。質問は今です:どのようにすべての子にロールバックを呼び出すCompositeFilterを使用し続けるのですか?

私はポーラー内の再試行アダプタを置くに(編集:私は今、これは無関係です知っている):見てきた

<bean id="retryAdvice" class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice"/> 

<int:poller fixed-rate="10000" max-messages-per-poll="-1"> 
    <int:advice-chain> 
     <tx:advice transaction-manager="transactionManager"/> 
     <int:ref bean="retryAdvice"/> 
    </int:advice-chain> 
</int:poller> 

を...しかし、これはその

This advice org.springframework.integration.handler.advice.RequestHandlerRetryAdvice can only be used for MessageHandlers 
警告をスローします

要するに、私は立ち往生しています。この種のsftp例外を再試行するための助けとなることは、非常に感謝して受け取ります。ありがとう!

EDIT:SftpPersistentAcceptOnceFileListFilterの記載に追加されました。 EDIT:CompositeFileLIstFilterの説明を追加しました。これは問題の場所に似ています。

答えて

1

リトライアドバイスは、エンドポイントを消費する(プッシュリトライする)ためのものです。

あなたがここにリトライを追加する必要がある理由は明らかではない - ポーラーは、本質的に次のポーリングに再試行されます。

+0

返信ありがとうございます - 公正なポイント。上記のmyFilterにはSftpPersistentAcceptOnceFileListFilterが含まれています(これについては編集する予定です)。これを取り除くと、あなたが記述したように再試行の動作が得られます。おそらく私の質問は、最初のいくつかの失敗した試行でPropertiesPersistingMetadataStoreにダウンロードされたファイルをマークしない方法です。 – Liche

+0

OK、私はここに長い道のりに掘ったと私は問題が何らかの理由でそのすべての複合材料のロールバックを呼び出すことではないCompositeFileListFilterであると思います。カスタムFileListFilterクラスの実装を超えてこれを修正する方法が不明な場合は、歓迎します。 – Liche

+0

どのSpring Integrationのバージョンを使用していますか? 'CompositeFileListFilter'は[4.2.1および4.1.7(https://github.com/spring-projects/spring-integration/pull/1579)に可逆作製しました。 –