Created 10-25-2017 01:49 PM
I want to make transfer operation when i will have certain amount of flowFile in my flowFile queue, and i make remove operation for unused File . Can remove operation cause to dissapear flowfile from my flowfile array list ? here is my code:
import org.apache.commons.io.IOUtils import java.nio.charset.StandardCharsets import groovy.lang.* def flowFile=session.get(); def name=flowFile.getAttribute("realName") def count=flowFile.getAttribute("count") def filename=flowFile.getAttribute("filename") def value= count as Double; def numb=Math.round(value) def List<FlowFile> flowFiles= new ArrayList<>(); flowFiles.add(flowFile) if(flowFiles.size()==numb){ for(FlowFile i in flowFiles){ if(i.getAttribute("filename").substring(0,10)==name){ session.transfer(i,REL_SUCCESS); } } } else{ session.remove(flowFile); }
Created 10-25-2017 07:10 PM
If you are waiting for X number of flow files to be received, you can use something like this (assuming you want 10 flow files):
def flowfileList = session.get(10) if(flowfileList.size() < 10) { session.rollback() return } // If you get here, you have 10 flowfiles in flowfileList
Created 10-25-2017 07:10 PM
If you are waiting for X number of flow files to be received, you can use something like this (assuming you want 10 flow files):
def flowfileList = session.get(10) if(flowfileList.size() < 10) { session.rollback() return } // If you get here, you have 10 flowfiles in flowfileList