【问题标题】:Spring Boot will not start when using Spring Integration and JdbcMetadataStore使用 Spring Integration 和 JdbcMetadataStore 时 Spring Boot 不会启动
【发布时间】:2018-10-22 17:51:11
【问题描述】:

我正在尝试使用 Spring Integration 通过SFTP 读取文件,并使用多个服务器仅读取每个文件一次。我已经在 Spring Boot 中配置了 SFTP 阅读器,它可以与内存中的元数据存储一起使用。当我使用 Postgres 配置 JdbcMetadataStore 时,Spring boot 将不再启动,并且除了 Tomcat 正在关闭之外没有错误消息。我正在使用带有 JPA 和 Spring WS 的 Spring Boot

2018-10-22 11:16:06.098  INFO 6775 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-10-22 11:16:06.106  INFO 6775 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'metadataStore' has been autodetected for JMX exposure
2018-10-22 11:16:06.114  INFO 6775 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Located managed bean 'metadataStore': registering with JMX server as MBean [org.springframework.integration.jdbc.metadata:name=metadataStore,type=JdbcMetadataStore]
2018-10-22 11:16:06.125  INFO 6775 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

我正在使用基于注释的配置

@Bean
public ConcurrentMetadataStore metadataStore(final DataSource dataSource) {
    return new JdbcMetadataStore(dataSource);
}

@Bean
public SessionFactory<ChannelSftp.LsEntry> sftpSessionFactory() {
    final DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true);
    factory.setHost(this.host);
    factory.setPort(this.port);
    factory.setUser(this.username);
    factory.setPassword(this.password);
    factory.setAllowUnknownKeys(true);
    return new CachingSessionFactory<>(factory);
}

@Bean
@InboundChannelAdapter(channel = "stream", poller = @Poller(fixedDelay = "5000"))
public MessageSource<InputStream> sftpMessageSource(ConcurrentMetadataStore metadataStore) {
    final SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(), null);
    messageSource.setRemoteDirectory("/");
     messageSource.setFilter(new SftpPersistentAcceptOnceFileListFilter(metadataStore,
             "INT_"));
    //messageSource.setFilter(new SftpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(),
    //        "streaming"));
    return messageSource;
}

@Bean
@Transformer(inputChannel = "stream", outputChannel = "data")
public org.springframework.integration.transformer.Transformer transformer() {
    return new StreamTransformer();
}

@Bean
public SftpRemoteFileTemplate template() {
    return new SftpRemoteFileTemplate(sftpSessionFactory());
}

【问题讨论】:

  • 这是一个很常见的设置。您是否有任何特定的日志记录设置可以防止显示错误?也许您应该尝试--debug 看看您是否可以获得更多信息。 PS:在 Sprint 集成中,错误/异常默认发送到错误通道,也许你禁用它?
  • 从你的代码中看不出任何明显的东西,一切看起来都很典型。尝试打开 DEBUG 日志记录以从日志中获取更多信息。
  • 我进行了完整的跟踪,除了在将其添加到 JMX 后它正在死亡之外,没有任何迹象表明错误在哪里

标签: spring spring-boot spring-integration spring-integration-sftp


【解决方案1】:

我注意到尝试将元数据存储加载到 JMX 时失败。然后我在 Spring Boot 中禁用了 JMX,它解决了这个问题。不知道为什么它无法将 bean 添加到 JMX 但在 spring boot 属性(yml)文件中禁用 JMX 解决了这个问题。

弹簧: 杰姆斯: 启用:假

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-15
    • 2018-03-10
    • 2018-10-03
    • 2017-04-29
    • 1970-01-01
    • 2015-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多