1 回答

TA貢獻1842條經(jīng)驗 獲得超13個贊
根據(jù)Spring中的Java和Annotation配置,inboundAdapter
bean名稱(本質(zhì)上是bean方法名稱)被準(zhǔn)確地分配給您聲明為bean的內(nèi)容。在您的情況下,它是一個MessageSource
實現(xiàn)。您確實需要在控制總線命令中處理通過那個SourcePollingChannelAdapter
分配給您的 bean?。唯一的問題是我們需要找出一個正確的 bean 名稱以從命令中引用它:MessageSource
@InboundChannelAdapter
AbstractEndpoint bean 名稱使用以下模式生成:[configurationComponentName].[methodName].[decapitalizedAnnotationClassShortName]。例如,前面顯示的 consoleSource() 定義的 SourcePollingChannelAdapter 端點獲取 myFlowConfiguration.consoleSource.inboundChannelAdapter 的 bean 名稱。另請參見端點 Bean 名稱。
因此,我建議您參考端點 Bean 名稱@EndpointId
建議,并與它一起使用@InboundChannelAdapter
:
@Bean
@InboundChannelAdapter(channel = "adapterOutputChanel", autoStartup = "false", poller = @Poller(fixedDelay = "1000"))
@EndpointId("myInboundAdapter")
public MessageSource<String> inboundAdapter() {
因此,您的控制總線命令將如下所示:"@myInboundAdapter.start()"
更新
用于連接的 Java DSL 變體MessageSource:
@Bean
public IntegrationFlow channelAdapterFlow() {
? ? return IntegrationFlows.from(new MyMessageSource(),?
? ? ? ? ? ? ? ? e -> e.id("myInboundAdapter").autoStartup(false).poller(p -> p.fixedDelay(100)))
? ? ? ? ? ? .channel(adapterOutputChanel())
? ? ? ? ? ? .get();
}
添加回答
舉報