私はSpring Integrationに問題があります。私は春のブート1.4.0を使用しています。リリース、春の統合4.3.1.RELEASE、春の統合DSL 1.2.0.M1。私は、ファイルを使用して(ローカルの作業ディレクトリにファイルを転送、FTPからファイルを読み込みますアプリケーションと(インバウンドチャネルアダプタを使用して)ローカルファイルシステムを書いているSpring統合DSL - ヘッダーにアクセスできるアウトバウンドゲートウェイ
:私は何をしようとしている
アウトバウンドゲートウェイ)を処理して、それらを最終的な宛先(ファイルアウトバウンドゲートウェイ/アダプタ)に移動します。
EDIT:元の問題は、OutboundGateway
の誤った使用に起因していました。私が間違っていたことの詳細については、編集履歴を見てください。
メッセージヘッダーの情報が必要なOutboundGateway
の配線に問題があります。
私の基本的な流れは次のとおりです。
@Bean
@SuppressWarnings("unchecked")
public IntegrationFlow fileSystemReadingFlow() {
LOGGER.debug("Building fileSystemReadingFlow.");
// Create a FileInboundChannelAdapter
return IntegrationFlows.from(s -> s.file(new File(StringUtils.cleanPath(Paths.get(directoryProperties.getLocal() , UNKNOWN).toString())))
// Add a Filter to restrict which files are retrieved
.filter(fileListFilterBuilder.buildFileListFilter(File.class))
// Add a poller to continually watch the directory
, endpointConfigurer -> endpointConfigurer.poller(poller)
)
.enrichHeaders(h -> h.header(FOLDER_NAME, LOCAL))
.handle((message, headers) -> Files.outboundGateway(new File(StringUtils.cleanPath(Paths.get(directoryProperties.getWorking()
, (String) headers.get(FOLDER_NAME)).toString()))).deleteSourceFiles(true).autoCreateDirectory(true))
// Send the files to the aggregatingChannel
.channel("aggregatingFileChannel")
.get();
}
問題がhandle((message, headers) -> Files.outboundGateway(...)
セクションです。上記のラムダメソッドを使用すると、このエラーは何度も繰り返されます。
ErrorMessage [payload=org.springframework.messaging.MessagingException: failed to resolve channel name 'org.springframework.integration.dsl.file.FileWritingMessageHandlerSpec'; nested exception is org.springframework.messaging.core.DestinationResolutionException: failed to look up MessageChannel with name 'org.springframework.integration.dsl.file.FileWritingMessageHandlerSpec' in the BeanFactory.; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.integration.dsl.file.FileWritingMessageHandlerSpec' is defined, headers={id=e3f5f341-6379-0dd0-11e6-e4bff8f455b0, timestamp=1471619276894}]
ドキュメントとテストでは、以下のように定義することがわかります。しかし、どうすればヘッダーにアクセスできますか?
.handle(Files.outboundGateway(new File("someDir"))).deleteSourceFiles(true).autoCreateDirectory(true))
正しい方法かもしれないSpEl式を使用しようとしましたが、動作させませんでした。
.handle(Files.outboundGateway("StringUtils.cleanPath(Paths.get(directoryProperties.getWorking()" +
", headers[FOLDER_NAME]).toString())").deleteSourceFiles(true).autoCreateDirectory(true))
素晴らしい!私はあなた自身の答えでさえ受け入れることができると思います。 –