Search code examples
apache-nifi

Accessing the parameter by dynamic name


How to access the parameter #{...} in Process configuration field if its name needs to be changed dynamically (for example, the name of this parameter is contained in some FlowFile attribute OR the name generating using expression language).

Illustrative example – for the LogMessage process, I have prepared several parameters in (msg1, msg2, msg3 etc.) that I would like to output depending on the attribute numofmessage

Field Log message for LogMessage process


Solution

  • Currently you cannot use EL inside of a parameter reference. If you put something like #{${abc}} it will look for a parameter named ${abc} and won't find one so it will be invalid.

    You can only do the reverse, use parameter inside of EL, for example ${ #{abc}:replace('xxx', 'zzz') }.

    In general, parameters are meant to be a better version/replacement for the existing variables functionality, but in this case variables may work better for you since variables are referenced through EL.