我想从成功队列中只获取一个第一个flowFile,并将其数据用于以后的进程,然后将其从进程会话中删除。当我获取此文件并将其数据提取到另一个流文件时,我在物理上进行session.remove()
操作的已使用的流文件处于成功队列中。我应该如何防止这种情况?这是我的工作流程代码和照片:
WORKFLOWF IMAGE
import org.apache.commons.io.IOUtils
import java.nio.charset.StandardCharsets
import groovy.lang.*
def flowfileList = session.get(1)
if(flowfileList.size() >1) {
session.remove(flowfileList)
return
}
def name=""
def count=" "
def filename=" "
def value= 0.0;
def numb=0;
def tryOnce=0;
for(FlowFile f in flowfileList){
name=f.getAttribute("realName")
count=f.getAttribute("count")
filename=f.getAttribute("filename")
value= count as Double;
numb=Math.round(value)
}
session.remove(flowfileList);
while(tryOnce<1){
def flowFile=session.create();
flowFile=session.putAttribute(flowFile,"filename",filename)
flowFile=session.putAttribute(flowFile,"name",name)
flowFile=session.putAttribute(flowFile,"count",numb.toString())
flowFile=session.putAttribute(flowFile,"check","this")
tryOnce=tryOnce+1
session.transfer(flowFile,REL_SUCCESS)
}