我正在尝试将XML中的file:outbound-gateway
配置转换为Java配置,但无法找到正确的API。
XML:
<file:outbound-gateway directory="file:myDir"
request-channel="inFiles" auto-create-directory="true"
delete-source-files="true" reply-channel="outFiles">
</file:outbound-gateway>
这是我迄今为止在Java配置上所拥有的。不确定如何设置request-channel
和reply-channel
:
@Bean
public MessageHandler fileOutBoundGateway() {
FileWritingMessageHandler gateway = new FileWritingMessageHandler(new File("myDir"));
gateway.setDeleteSourceFiles(true);
gateway.setAutoCreateDirectory(true);
// FIXME need to set request and reply channel
return gateway;
}
答案 0 :(得分:1)
request-channel
(inputChannel
)是endpoint
的选项。在您的情况下,您只有channel
和MessageHandler
,但仍然没有endpoint
。
只有你需要的是service-activator
:
@Bean
@ServiceActivator(inputChannel = "input")
public MessageHandler fileOutBoundGateway() {
FileWritingMessageHandler gateway = new FileWritingMessageHandler(new File("myDir"));
gateway.setDeleteSourceFiles(true);
gateway.setAutoCreateDirectory(true);
gateway.setOutputChannel(outputChannel());
return gateway;
}
请在Reference Manual中找到更多信息。 另请注意Java DSL。