Selvam, Are those two branches meeting at the same RouteOnAttribute (aka filterpoint)? If so, I'm assuming you'd like the GetFile/ExtractText to inform the RouteOnAttribute processor how to handle the flow files coming in from the other branch (please correct me if I've misunderstood). In Flow-Based Programming, this is usually done with an OPTIONS input, but NiFi doesn't have named inputs (for now), so the behavior instead is to take flow files from either input as they are available (perhaps in round-robin fashion).
You might be able to get this done by storing the conditions in a DistributedMapCache, but the GetFile/ExtractText (followed by PutDistributedMapCache) would need to be executed first (or you'd need logic in your other branch to retry until available). This might get fairly complicated for your use case. If you are comfortable with a language like Groovy, JavaScript, Jython, JRuby, or Lua, you can make this work with the ExecuteScript processor (if all you need are success and failure relationships) or InvokeScriptedProcessor (if you need to arbitrarily define relationships). For the former case, you'd read in the file directly from disk (possibly caching the conditions in State Management to avoid reading in the file on every execution), then accept incoming flow files (from your branch #2) and route to success or failure as you would do for matched/unmatched in RouteOnAttribute. Although InvokeScriptedProcessor takes more code/boilerplate, it also has the feature of having its initialize method called once, so you could read in the file there and not have to cache it in State Management, it would remain in the scripted processor instance while the processor is running. If the file is small and you don't mind the performance hit from reading it in every time the processor is triggered (especially if that file can change on-the-fly), then ExecuteScript would suffice. I can help with a Groovy script for this if you are interested, or if you want to give it a try and run into any trouble, please let me know. Regards, Matt On Sat, Oct 8, 2016 at 4:08 PM, Selvam Raman <[email protected]> wrote: > Hi, > > In your example you have hard coded the condition in updateonattribute and > what am trying is pass that condition dynamically from file. Aim of the flow > is tomorrow we don't want to touch the flow file to change the condition > whereas we have to change only the file. > > My aim is to create a flow where user has to give a file. File contain list > of table name which has to remove on the flow. > > Example: > Database contains following table > test1 > test2 > test3 > test4 > test5 > > File contains > test3 > > ExecuteSql should run only for > test1 > test2 > test4 > test5 > > I tried the below flow which is not working.(I know this is wrong approach > as get file generate flow file which will go executesql this should not > happen). I just shared what i tried. > > routeonattribute(filterpoint) > > 1) GetFile->ExtractText->filterpoint > 2) Listdatabasetable ->filterpoint -> (unmatched) ExecuteSql > > > If you get on idea please let me know. Right now i am changing > routeonattribute value manually. Expectation is convert to automatic. > > > > On Fri, Oct 7, 2016 at 7:42 PM, Andy LoPresto <[email protected]> wrote: >> >> Hi Selvam, >> >> I talked to Bryan and we figured out a way you can do this now. Despite my >> response on the other thread, you don’t even need the *literal* operator to >> accomplish this. I’ve included a link to a template [1] that accomplishes >> this, but the long and short of it is just to compare the attribute >> “expression” to the literal value ‘true' in your RouteOnAttribute. This will >> compare the String ‘true’ or ‘false’ to the String literal ‘true’ and return >> a boolean result. In this example I used matched/unmatched, but I also tried >> an example where I made two dynamic relationships and routed on the >> relationship name, and that worked as well. Good luck. >> >> [1] https://gist.github.com/alopresto/e0458804c642339c5bb32dd9a008f2c5 >> >> >> Andy LoPresto >> [email protected] >> [email protected] >> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69 >> >> On Oct 7, 2016, at 6:25 AM, Bryan Bende <[email protected]> wrote: >> >> Selvam, >> >> I don't believe there is a way to do this right now. >> >> Your scenario requires two-levels of evaluation... it first needs to >> evaluate ${expression} to get the value of that, then it needs to do it >> again to evaluate the resulting expression. >> >> Currently that is not how expression language works, it only performs the >> first evaluation and in the case of RouteOnAttribute that needs to return a >> boolean. >> >> -Bryan >> >> >> On Fri, Oct 7, 2016 at 4:41 AM, Selvam Raman <[email protected]> wrote: >>> >>> Hi Bran, >>> >>> I have an expression in file that have more than 10 condition. I am >>> reading a file using list and fetchs3. Using extracttext i am extracting as >>> attribute (test). >>> >>> I am trying to use test in routeonattribute but it shows an error like it >>> was expecting boolean but having string value. >>> >>> please let me know if you have any question. >>> >>> Thanks, >>> selvam R >>> >>> Thanks, >>> Selvam R >>> >>> On Thu, Oct 6, 2016 at 8:57 PM, Bryan Bende <[email protected]> wrote: >>>> >>>> Hello, >>>> >>>> I'm not totally sure, but I think this creates two levels of expression >>>> language and won't work. >>>> >>>> Typically the flow file would have an attribute like db.table.name and >>>> then in RouteOnAttribute you would define a property like test = >>>> ${db.table.name:equals('test')}. >>>> >>>> -Bryan >>>> >>>> On Thu, Oct 6, 2016 at 3:31 PM, Selvam Raman <[email protected]> wrote: >>>>> >>>>> Hi, >>>>> >>>>> can we refer to an attribute from a previous processor for specifying a >>>>> boolean clause in routeonattribute processor. >>>>> >>>>> For Eg. : A flowfile from a previous processor has a attribute called >>>>> expression with value ${db.table.name:equals('test')} . Can we refer to >>>>> this >>>>> ${expression} attribute as a boolean clause in routeonattribute processor >>>>> ? >>>>> >>>>> -- >>>>> Selvam Raman >>>>> "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து" >>>> >>>> >>> >>> >>> >>> -- >>> Selvam Raman >>> "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து" >> >> >> > > > > -- > Selvam Raman > "லஞ்சம் தவிர்த்து நெஞ்சம் நிமிர்த்து"
