0
我想知道如何取消訂閱文件通道。我試圖在我的服務中引導頻道並調用取消訂閱方法,但我無法訪問消息處理程序,因此我正在使用FileReadingMessageSource
。有什麼想法嗎?如何在Spring集成中取消訂閱文件通道?
我想知道如何取消訂閱文件通道。我試圖在我的服務中引導頻道並調用取消訂閱方法,但我無法訪問消息處理程序,因此我正在使用FileReadingMessageSource
。有什麼想法嗎?如何在Spring集成中取消訂閱文件通道?
您需要顯示您的配置,但通常您要停止引用源的SourcePollingChannelAdapter來停止適配器。您不想取消訂閱,除非適配器停止,否則會導致錯誤。
編輯
您的配置,如果入站適配器是在一個名爲IntegrationCongfig
類,它的bean名字會integrationConfig.test.inboundChannelAdapter
(注意小寫i
)...
@Autowired
@Qualifier("integrationConfig.test.inboundChannelAdapter")
private SourcePollingChannelAdapter test;
@Autowired
private StandardIntegrationFlow processFileFlow;
.. 。
this.test.stop(); // stop the adapter
this.processFileFlow.stop(); // stops all components in the flow
停止流程將取消訂閱處理程序e頻道;但你必須先停止適配器。
這裏是我的配置:@Bean \t公共MessageChannel fileInputChannel(){返回新DirectChannel();} // @豆 \t公共IntegrationFlow processFileFlow(){回報IntegrationFlows \t。從 「fileInputChannel」 \t .handle(」 incomingFileProcessor「,」validateAndStartJob「)。get(); \t} @Bean \t @InboundChannelAdapter(值= FILE_INPUT_CHANNEL,輪詢器= @Poller(FIXEDDELAY = _1000)) 公共FileReadingMessageSource試驗(@Value( 「$ {dirPath}」)字符串目錄){返回monitorDirectory(目錄);} – ram533
不要在評論中放置代碼;你可以看到它很難閱讀;在將來,編輯問題,並添加一個你已經這樣做的評論。看到我的答案編輯。 –