![](/img/trans.png)
[英]@ServiceActivator without @MessageEndpoint in Spring Integration annotation config
[英]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()
會被調用嗎? 我理解對了嗎?
好吧,您需要了解這件事有兩個部分:
AppplicaitonContext
中注冊 bean 的配置階段。 這樣,即使是@ServiceActivator
也會被咨詢,並且事件驅動的端點也被注冊為 bean。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.