Talend tWaitForFile 不足 [英] Talend tWaitForFile insufficiency
问题描述
我们有一个生产者进程将文件写入特定文件夹,该进程持续运行,我们必须使用talend逐个读取文件,有2个问题:
We have a producer process that write files into a specific folder, which run continuously, we have to read files one by one using talend, there is 2 issues:
- 第一个:tWaitForFile 只读在它启动之前存在的文件,所以在组件启动之后创建的文件对其不可见.
- 第二:无法知道文件是否被生产者进程释放,可能在没有完全写入的情况下被读取,tWaitForFile的参数_wait_release_在Linux系统上不起作用!
那么如何让 Talend 从文件数不断增加的目录中读取完整的写入文件?
So how can make Talend read complete written files from a directory that have an increasing files number ?
推荐答案
我不知道你说的第一个问题是什么意思.tWaitForFile 具有在文件夹中创建、修改或删除文件时触发的选项.
I'm not sure what you mean by your first issue. tWaitForFile has options to trigger when files are created, modified or deleted in a folder.
至于第二个问题,最好的办法是文件制作者在完成写入所需文件后创建一个 OK 或控制文件,该文件是 0 字节触摸.
As for the second issue, your best bet here is for the file producer to be creating an OK or control file which is a 0 byte touch when it has finished writing the file you want.
在这种情况下,您只需查找 OK 文件的外观,然后选择相关的已完成文件即可.如果您将这 2 个文件命名为相同但具有不同的文件扩展名(OK 文件通常称为.OK",那么这应该很容易查找.因此您可以将 tWaitForFile 设置为查找*.OK"文件然后将其连接到迭代到 tFileInputDelimited(在您想要获取分隔文本文件的情况下),然后将文件名声明为 ((String)globalMap.get("tWaitForFile_1_CREATED_FILE")).substring(0,((String)globalMap.get("tWaitForFile_1_CREATED_FILE")).length()-3) + ".txt"
In this case you simply look for the appearance of the OK file and then pick up the relevant completed file. If you name the 2 files the same but with a different file extension (the OK file is typically called ".OK" then this should be easy enough to look for. So you would set your tWaitForFile to look for "*.OK" files and then connect this to an iterate to a tFileInputDelimited (in the case you want to pick up a delimited text file) and then declare the file name as ((String)globalMap.get("tWaitForFile_1_CREATED_FILE")).substring(0,((String)globalMap.get("tWaitForFile_1_CREATED_FILE")).length()-3) + ".txt"
我在下面提供了一些屏幕截图以帮助您:
I've included some screenshots to help you below:
这篇关于Talend tWaitForFile 不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!