Spring Boot не запускается при использовании Spring Integration и JdbcMetadataStore - PullRequest
0 голосов
/ 22 октября 2018

Я пытаюсь использовать Spring Integration для чтения файлов через SFTP и использовать несколько серверов для чтения каждого файла только один раз.Я настроил SFTP считыватель в Spring Boot, и он работает с хранилищем метаданных в памяти.Когда я настраиваю JdbcMetadataStore с использованием Postgres, загрузка Spring больше не запускается, и не появляется сообщение об ошибке, кроме Tomcat, который завершает работу.Я использую Spring Boot с JPA и Spring WS

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());
}

1 Ответ

0 голосов
/ 23 октября 2018

Я заметил, что это не удалось при попытке загрузить метаданные в JMX.Затем я отключил JMX в Spring Boot, и это исправило проблему.Не уверен, почему не удалось добавить компонент в JMX, но отключение JMX в файле свойств весенней загрузки (yml) устранило проблему.

spring: jmx: enabled: false

...