[英]Spring Integration File Support
在Spring Integration中,如何防止兩個不同的機器在同一個文件中工作? 我知道nio庫(javaSE)提供了一種鎖定File FileLocker的機制,但是如何使用Spring Integration實現它呢? 一個具體的例子將不勝感激。
確實有一個org.springframework.integration.file.locking.NioFileLocker
實現,可用於FileReadingMessageSource
選項,例如:
/**
* Optional. Sets a {@link FileLocker} to be used to guard files against
* duplicate processing.
* <p>
* <b>The supplied FileLocker must be thread safe</b>
* @param locker a locker
*/
public void setLocker(FileLocker locker) {
從XML角度來看,它是這樣的:
<file:inbound-channel-adapter>
<file:nio-locker/>
</file:inbound-channel-adapter>
更多信息在參考手冊中 。
避免在不同的JVM中進行並發訪問和復制的另一種方法是將FileSystemPersistentAcceptOnceFileListFilter
與共享的持久性ConcurrentMetadataStore
: https : //docs.spring.io/spring-integration/docs/5.0.3.RELEASE/reference/html/files.html #文件讀取
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.