spring集成

rvpgvaaj  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(477)

我正在尝试使用rotatingserveradvice从多个资源轮询新文件。我有一个新的要求,即对于每个新的客户机,在sftp服务器中创建一个新的目录,并且我还想将该目录添加到轮询中。所以我将使用int-sftp:outbound-gateway to 查询所有目录并检查是否创建了新目录,然后将新目录添加到关键目录中。有可能是那样吗?谢谢您。

@Bean
public RotatingServerAdvice advice() {
  List<RotationPolicy.KeyDirectory> keyDirectories = new ArrayList<>();
  keyDirectories.add(new RotationPolicy.KeyDirectory("one", "foo"));
  keyDirectories.add(new RotationPolicy.KeyDirectory("one", "bar"));
  keyDirectories.add(new RotationPolicy.KeyDirectory("two", "baz"));
  keyDirectories.add(new RotationPolicy.KeyDirectory("two", "qux"));
  keyDirectories.add(new RotationPolicy.KeyDirectory("three", "fiz"));
  keyDirectories.add(new RotationPolicy.KeyDirectory("three", "buz"));
  return new RotatingServerAdvice(delegatingSf(), keyDirectories);
}
ne5o7dgx

ne5o7dgx1#

默认情况下是不可能的 StandardRotationPolicy ; 你需要提供一个自定义 RotationPolicy .

/**
 * Construct an instance that rotates according to the supplied
 * {@link RotationPolicy}.
 * @param rotationPolicy the policy.
 */
public RotatingServerAdvice(RotationPolicy rotationPolicy) {
    Assert.notNull(rotationPolicy, "'rotationPolicy' cannot be null");
    this.rotationPolicy = rotationPolicy;
}

你可以从 StandardRotationPolicy 作为一个模特。

相关问题