【问题标题】:Programmatically start and stop certain IntegrationFlows in Spring Integration?在 Spring Integration 中以编程方式启动和停止某些 IntegrationFlows?
【发布时间】:2017-09-14 10:24:03
【问题描述】:

我在 Spring 集成中创建了一些 IntegrationFlow,如下所示:

IntegrationFlows.from(..).id("test").autoStartup(false). ..

如何在 Spring Integration 中查找此集成流程并启动它?我正在寻找类似于org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry 的东西,可以用来启动和停止RabbitListener 实例。

【问题讨论】:

    标签: java spring spring-integration


    【解决方案1】:

    使用流的bean名称

    @Bean
    public IntegrationFlow flow() {...}
    
    
    ...
    
    
    @Autowired
    public IntegrationFlow flow;
    
    ...
    
    flow.stop();
    

    (或ApplicationContext 上的getBean("flow"))。

    【讨论】:

    • 也许这应该读作StandardIntegrationFlow 而不是IntegrationFlow,因为.stop() 是为前者而不是后者定义的。也许自 2017 年以来 API 发生了变化,但 Spring Integration 5.x 就是这种情况?
    • 你是对的;或者您可以将IntegrationFlow 转换为SmartLifecycleIntegrationFlow 应该可以扩展 SmartLifecycle。请打开一个 GitHub 问题。
    猜你喜欢
    • 1970-01-01
    • 2011-06-13
    • 1970-01-01
    • 2017-11-10
    • 1970-01-01
    • 1970-01-01
    • 2023-01-24
    • 2011-03-30
    • 1970-01-01
    相关资源
    最近更新 更多