有没有一种方法可以在使用java配置从sftp服务器接收文件后停止入站通道适配器

问题描述:

如何启动/停止入站通道适配器,我试过使用控制总线但是我没有成功,请提供一个java配置的例子。有没有一种方法可以在使用java配置从sftp服务器接收文件后停止入站通道适配器

+0

请提供你尝试过什么到目前为止的例子。控制总线和'stop()'调用是正确的方式,但我们应该确定任何方式的代码。 –

@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()")); 
+0

非常感谢你Artem ..得到它并实施... – user2573586

+0

听起来不错!现在考虑一下:https://stackoverflow.com/help/someone-answers –