• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Groovy code doesn't work properly

 
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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()
}
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic