Spring Integration Control Bus configuration via annotations

后端 未结 2 569
刺人心
刺人心 2021-01-05 19:06

Just a simple question: Is there any way to configure Spring Integration Control Bus via annotations (without any xml)



        
相关标签:
2条回答
  • 2021-01-05 19:34
    @Bean
    @ServiceActivator(inputChannel = "controlBusChannel")
    public ExpressionControlBusFactoryBean controlBus() throws Exception {
        ExpressionControlBusFactoryBean controlBus = new ExpressionControlBusFactoryBean();
        return controlBus;
    }
    

    Note that any outputChannel on the annotation will be ignored; it is defined on the bus itself.

    Typically the output channel of a control bus is omitted with the result of normal request/reply operations, such as @someBean.isRunning() (if someBean implements Lifecycle for example) going back to the replyChannel header (e.g. to a MessagingTemplate.sendAndReceive() operation or a Messaging Gateway).

    If you need to send the control bus operation results some place else, add an output channel to the factory bean.

    Any MessageHandler @Bean (or a factory bean that creates one) can now be annotated with @ServiceActivator. See the documentation.

    0 讨论(0)
  • 2021-01-05 19:43

    The Spring Integration Java DSL provides the stuff on the matter:

    @Bean
    public IntegrationFlow controlBusFlow() {
         return IntegrationFlows.from("operationChannel").controlBus().get();
    }
    
    0 讨论(0)
提交回复
热议问题