簡體   English   中英

Spring 集成:SpringApplicationContext 在配置中調用@ServiceActivator 嗎?

[英]Spring integration : does SpringApplicationContext call @ServiceActivator in config?

我正在閱讀 Spring 集成源代碼,我對了解工作流程有一些疑問:

@SpringBootApplication class 在調用application.run()時是否會直接調用使用 @ServiceActivator 注釋的 bean? 例如在我的配置文件中,我有:

@Bean
@ServiceActivator(inputChannel = test)
public MessageHandler myHandler() {
   return new SomeHandler();
}

application.run()被觸發時, SomeHandler的方法handleRequestMessage()會被調用嗎? 我理解對了嗎?

好吧,您需要了解這件事有兩個部分:

  1. Spring 解析所有注解以在AppplicaitonContext中注冊 bean 的配置階段。 這樣,即使是@ServiceActivator也會被咨詢,並且事件驅動的端點也被注冊為 bean。
  2. Spring 集成環境的運行時部分。 這里提到的端點訂閱了inputChannel ,當消息到達時,從SomeHandler觸發handleRequestMessage() 這就是為什么它被稱為“服務激活器”。

您可能首先需要讓自己熟悉 EIP: https://www.enterpriseintegrationpatterns.com/以了解什么是消息傳遞以及為什么在它們之間存在端點和通道。 Then you go to Spring Integration docs: https://docs.spring.io/spring-integration/docs/current/reference/html/index.html and realize for yourself that this framework provides a bunch of out-of-the-這個或那個 EIP 的 box 組件可以通過聲明一些注釋在應用程序上下文中自動注冊。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM