Geoffrey,

Where are the two flowfiles coming from? This use case is often
handled in NiFi using LookupRecord with one of the LookupService
implementations (REST, RDBMS, CSV, etc.). We don't currently have a
mechanism (besides scripting) to do enrichment/lookups from flowfiles.

For your script, you can do session.get(2) and then check the size of
the returned List. If it is less than 2, you can rollback the session
and return (possibly yielding first if you don't want to check again
rapidly).

Regards,
Matt

On Tue, Nov 17, 2020 at 4:13 PM Greene (US), Geoffrey N
<geoffrey.n.gre...@boeing.com> wrote:
>
> I’m trying to glue two flow files together HORIZONTALLY.  That is,
>
> Flowfile1
>
> ID,STARTINGLETTER
>
> 1,A
>
> 2,B
>
>
>
> And flowfile2:
>
> ID, WORD
>
> 1,Apple
>
> 2, Ball
>
> 3, Cat
>
>
>
> I want it to become:
>
> ID, STARTINGLETTER, WORD
>
> 1,A,Apple
>
> 2,B,Ball
>
> 3,,Cat
>
>
>
> The only way I’ve been able to figure out how to do this is to write a custom 
> “InvokeGroovyProcessor” that takes two flowfiles reads them both, and then 
> concatenates them.
>
>
>
> I’m having trouble figuring out how to pop TWO flow files off the queue, (The 
> order doesn’t really matter for now), and write one. I’ve tried
>
>
>
>     @Override
>
>     void onTrigger(ProcessContext context, ProcessSessionFactory 
> sessionFactory) throws ProcessException {
>
>         try {
>
>             def session = sessionFactory.createSession()
>
>              while (session.getQueueSize() != 2)
>
>              {
>
>                      Thread.sleep(1000)
>
>                      log.debug("sleeping")
>
>               }
>
>              // we never get here
>
>               log.debug(“found two flow files")
>
>               // get BOTH flowfiles
>
>              def flowFileList = session.get(2)
>
>               def flowFile1 = flowFileList.get(0)
>
>               def flowFile2 = flowFileList.get(1)
>
>                                // now do the glue
>
>
>
> Or Is there a better way?
>
> Thanks!
>
>
>
>
>
>
>
> Geoffrey Greene
>
> Senior Software Ninjaneer
>
> (703) 414 2421
>
> The Boeing Company
>
>

Reply via email to