• Post Reply Bookmark Topic Watch Topic
  • New Topic

Groovy code doesn't work properly  RSS feed

 
sally tkhilaishvili
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have several flowfiles in success queue in which I have parameter count and I have to transfer only counter amount of flowfiles, every time the counter value is different so any time I will have to get it from flowfile (all flowfiles from this success queue have this attribute), I have tried this logic below (I mean my code) and several modifications of it but I can't fulfill this task. Could you tell me what's wrong with this code?


import org.apache.commons.io.IOUtils
import java.nio.charset.StandardCharsets
import groovy.lang.*

def flowFile = session.get();
if (!flowFile)
    return;
int numb = (flowFile.getAttribute("count") as Double).round()
def filename = flowFile.getAttribute("filename")

def flowfileList = session.get(numb-1)

if (flowfileList.size() == numb-1) {
    session.transfer(flowfile,REL_SUCCESS);
    session.transfer(flowfileList,REL_SUCCESS);
} else {
    session.rollback()
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!