第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

將重命名的文件作為輸入傳遞給出站適配器/網(wǎng)關(guān)

將重命名的文件作為輸入傳遞給出站適配器/網(wǎng)關(guān)

嗶嗶one 2021-08-19 18:40:48
在 spring-boot-integration 應(yīng)用程序中,編寫(xiě)了一個(gè)自定義儲(chǔ)物柜以在鎖定之前重命名原始文件(fileToLock.getAbsolutePath() + ".lock")和預(yù)期鎖定文件,以便任何其他實(shí)例將無(wú)法處理相同的文件.當(dāng)文件重命名時(shí),它對(duì)原始文件和附加文件的內(nèi)容進(jìn)行處理,并使用帶有內(nèi)容的 filename.lock 創(chuàng)建,并且原始文件也存在大小為 0 kb 的無(wú)內(nèi)容。出站網(wǎng)關(guān)將原始文件作為沒(méi)有內(nèi)容的輸入并將其路由到目標(biāo)路徑。想知道如何重命名原始文件,或者如何將重命名的文件 filename.lock 作為輸入傳遞給出站網(wǎng)關(guān)/適配器。 <integration:chain id="filesOutChain" input-channel="filesOutChain">           <file:outbound-gateway id="fileMover"             auto-create-directory="true"            directory-expression="headers.TARGET_PATH"            mode="REPLACE">            <file:request-handler-advice-chain>                <ref bean="retryAdvice" />            </file:request-handler-advice-chain>        </file:outbound-gateway>            <integration:gateway request-channel="filesOutchainChannel" error-channel="errorChannel"/>    </integration:chain>自定義文件鎖:public class CustomFileLocker extends AbstractFileLockerFilter{private final ConcurrentMap<File, FileLock> lockCache = new ConcurrentHashMap<File, FileLock>();private final ConcurrentMap<File, FileChannel> channelCache = new ConcurrentHashMap<File, FileChannel>();@Overridepublic boolean lock(File fileToLock) {    FileChannel channel;    FileLock lock;    try {               boolean fileRename =fileToLock.renameTo(new File(fileToLock.getAbsolutePath() + ".lock"));        if(fileRename)        {        channel = new RandomAccessFile(fileToLock, "rw").getChannel();        lock = channel.tryLock();        if (lock == null || !lock.isValid()) {              System.out.println(" Problem in acquiring lock!!" + fileToLock.getName());            return false;        }        lockCache.put(fileToLock, lock);        channelCache.put(fileToLock, channel);           } catch (FileNotFoundException e) {        // TODO Auto-generated catch block        e.printStackTrace();    } catch (IOException e) {        // TODO Auto-generated catch block        e.printStackTrace();    }    return true;}@Overridepublic boolean isLockable(File file) {    return file.canWrite();}
查看完整描述

1 回答

?
ibeautiful

TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊

<file:outbound-gateway id="fileMover">在鏈中之前的這個(gè)怎么樣:

<integration:transformer expression="new java.io.File(payload.absolutePath + '.lock')"/>

?


查看完整回答
反對(duì) 回復(fù) 2021-08-19
  • 1 回答
  • 0 關(guān)注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)