Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Nifi:how to handle trnasfer 'transaction' based on flowFile amount in nifi?

avatar
Contributor

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);
    
    }


1 ACCEPTED SOLUTION

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
1 REPLY 1

avatar
Master Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login