Those variables are available to be referenced via Expression Language in the 
flowfile attributes. They are not intended for direct programmatic access via 
code, so you don’t need to address them directly in your Groovy code. 

If you need to populate specific values at configuration time, you can define 
dynamic properties on the processor config and reference those directly in code 
(see any existing processor source for examples).  

Andy LoPresto
alopre...@apache.org
alopresto.apa...@gmail.com
He/Him
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Aug 9, 2020, at 10:40 PM, Saloni Udani <saloniudani.t...@gmail.com> wrote:
> 
> Thanks Andy.
> 
> By variables I meant NiFi process group variables.
> <Screenshot from 2020-08-10 11-08-15.png>
> 
> On Sat, Aug 8, 2020 at 12:39 AM Andy LoPresto <alopre...@apache.org 
> <mailto:alopre...@apache.org>> wrote:
> I think we need additional clarification on what you mean by “variables”. If 
> you are referring to actual Groovy variables, you can enumerate them using 
> the binding available in the context (see below). If you mean the attributes 
> available on a flowfile, you can access them similarly. 
> 
> Find all variables starting with prefix: 
> 
> def varsStartingWithABC = this.binding.variables.findAll { k,v -> 
> k.startsWith(“a.b.c”) }
> 
> Find all attributes starting with prefix:
> 
> def attrsStartingWithABC = flowfile.getAttributes().findAll { k,v -> 
> k.startsWith(“a.b.c”) }
> 
> 
> 
> Andy LoPresto
> alopre...@apache.org <mailto:alopre...@apache.org>
> alopresto.apa...@gmail.com <mailto:alopresto.apa...@gmail.com>
> He/Him
> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
> 
>> On Aug 7, 2020, at 2:11 AM, Saloni Udani <saloniudani.t...@gmail.com 
>> <mailto:saloniudani.t...@gmail.com>> wrote:
>> 
>> Hi,
>> We use NiFi 1.5.0.
>> Our use case is to get particular key pattern variables (key and value) in 
>> the groovy InvokeScriptedProcessor. E.g I want all variables whose key 
>> starts with "a.b.c". By this I can write a generic logic on certain 
>> categories of variables for further use.
>> 
>> Is there a way programmatically to get all variables with a certain key 
>> pattern? Or for that matter is there a way programmatically to get all 
>> available variables Map ? In NiFi 1.5.0 or further versions.
>> 
>> 
>> Thanks
>> Saloni Udani
> 

Reply via email to