我使用 DSL 配置和 spring。
我的路线如下所示:
@Component
public class UploadRoutesDefinition extends RouteBuilder {
@Override
public void configure() throws Exception {
from("seda:rest_upload")
.process(new Processor() {
@Override
public void process(Exchange exchange) {
...
String sftPathForAdditionalFile = ....
String AdditionalFileContent = ...
...
}
).to(String.format(SFTP_BASE_URL,systemSettingsService.getSystemSettings().getSftpUserName(),
systemSettingsService.getSystemSettings().getSftpHost(),
systemSettingsService.getSystemSettings().getSftpPort(),
systemSettingsService.getSystemSettings().getSftpAttachmentsPushFailedPath(),
systemSettingsService.getSystemSettings().getSftpPassword()))
它允许我从中读取文件seda:rest_upload
,然后将其移动到 sftp 文件夹。
我想再移动一个文件。我知道方法内部的路径和内容process
。
我怎样才能实现它?
更新
我当前的代码;
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader("CamelFilename", "ololo.txt");
exchange.getIn().setBody(exchange.getProperty(PUSH_ERROR_MESSAGE, String.class).getBytes());
exchange.getIn().setHeader("destFilePath", sftpErrorFileTextPath);
}
})
.to(String.format(SFTP_BASE_URL + "&fileExist=Append",
systemSettingsService.getSystemSettings().getSftpUserName(),
systemSettingsService.getSystemSettings().getSftpHost(),
systemSettingsService.getSystemSettings().getSftpPort(),
"${header.destFilePath}",
systemSettingsService.getSystemSettings().getSftpPassword()))
.end();