【问题标题】:Is there a way to stop the inbound channel adapter after files are received from sftp server using java configuration有没有办法在使用 java 配置从 sftp 服务器接收文件后停止入站通道适配器
【发布时间】:2017-08-01 14:16:15
【问题描述】:

使用Java配置如何启动/停止入站通道适配器,我尝试使用控制总线但我没有成功,请提供一个java配置示例。

【问题讨论】:

  • 请提供一个示例,您到目前为止尝试过什么。控制总线和stop() 调用是正确的方式,但我们应该确保以任何方式在代码中。

标签: spring-integration spring-integration-sftp


【解决方案1】:

@InboundChannelAdapter 使用基于模式 [configurationComponentName].[methodName].[decapitalizedAnnotationClassShortName] 的名称填充 SourcePollingChannelAdapter bean。例如:

@Configuration
@EnableIntegration
public class MyConfiguration {

    @InboundChannelAdapter(channel = "inputChannel")
    @Bean
    public MessageSource<String> myMessageSource() {
        return () -> new GenericMessage<>("bar");
    }

}

将有一个 bean 名称为 myConfiguration.myMessageSource.inboundChannelAdapter

SourcePollingChannelAdapter 确实是Lifecycle,可以由控制总线管理:

controlBusChannel.send(
      new GenericMessage("@'myConfiguration.myMessageSource.inboundChannelAdapter'.stop()"));

【讨论】:

    猜你喜欢
    • 2015-09-06
    • 2014-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-04
    • 2018-07-06
    • 1970-01-01
    • 2020-11-10
    相关资源
    最近更新 更多