apacheminifyapache-nifihortonworks-data-platformhortonworks-dataflow

How to read values dynamically from a file for a property in updateAttribute?


I added some custom properties in the 'updateAttribute' processor using the '+' button. For example: I declared a property 'DBConnectionURL' and gave the value as 'jdbc:mysql://localhost:3306/test'. Then, in the 'DBCPConnectionPool' service controller, I simple used the value'${DBConnectionURL}' for 'Database Connection URL' property. But, I manually gave the value for 'DBConnectionURL' property.I want a way where I can feed the value dynamically from a file, so that i just need to change the value in the file and the value for 'DBConnectionURL' changes dynamically based on the value present in the file. Is there a way to do it?


Solution

  • Rishab,

    You have to use nifi variable registry.

    In conf/nifi.properties, you could configure the below configuration in it for dynamically update a value in your data flow.

    nifi.variable.registry.properties=./dynamic.properties
    

    You can give your variables in that file dynamic.properties it should present in conf directory.

    For an example, If dynamic.properties files contains below values

    DBCPURL= jdbc://<host>:<port>
    

    you can use that in your data flow by using ${DBCPURL}

    Note: You should restart nifi services if you change any configuration in conf/nifi.properties.Otherwise your changes not worked in dataflow.

    Feel free to accept it be answer if it worked for you.