2017-08-01 133 views
1

我試圖在春季的一個程序,它進行數據庫輪詢並選擇該記錄讀取。我看到xml的例子,但我想知道我們在java配置中如何做。有人能給我看一個例子嗎?春季Jdbc入站通道適配器

回答

0

你需要JdbcPollingChannelAdapter@Bean定義,標有@InboundChannelAdapter

@Bean 
@InboundChannelAdapter(value = "fooChannel", poller = @Poller(fixedDelay="5000")) 
public MessageSource<?> storedProc(DataSource dataSource) { 
    return new JdbcPollingChannelAdapter(dataSource, "SELECT * FROM foo where status = 0"); 
} 

http://docs.spring.io/spring-integration/docs/4.3.11.RELEASE/reference/html/overview.html#programming-tips

+0

Ok..but怎麼去處理該記錄 – sash84

+0

'@ ServiceActivator'是有你消耗從消息'fooChannel':http://docs.spring.io/spring-integration/docs/4.3.11.RELEASE/reference/html/configuration.html#annotations –

+0

嗨,你能解釋一下服務執行器的方法,用於使用jdbc記錄嗎? – sash84

相關問題