Skip to content

Instantly share code, notes, and snippets.

@YolandaMDavis
Created July 15, 2016 23:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save YolandaMDavis/364307c1ab5fe89b2edcef5647180873 to your computer and use it in GitHub Desktop.
Save YolandaMDavis/364307c1ab5fe89b2edcef5647180873 to your computer and use it in GitHub Desktop.
Custom Property Support in EL Demo for NiFi
nifi.custom.variable.1=yes
nifi.custom.variable.2=maam
nifi.custom.attributes.dir=/Users/ydavis/dev/tools/attributes
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><template encoding-version="1.0"><description>This flow demonstrates use of custom properties in EL with UpdateAttributes processor and the PutFile processor</description><groupId>53d29129-3b42-40ab-a008-81ebb557b334</groupId><name>CustomPropertyDemo</name><snippet><connections><id>748758a2-2eb8-42fe-8fc6-d11d467c1e6c</id><parentGroupId>53d29129-3b42-40ab-a008-81ebb557b334</parentGroupId><backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold><backPressureObjectThreshold>10000</backPressureObjectThreshold><destination><groupId>53d29129-3b42-40ab-a008-81ebb557b334</groupId><id>4045eff6-fafc-4979-9138-b63d465c059a</id><type>PROCESSOR</type></destination><flowFileExpiration>0 sec</flowFileExpiration><labelIndex>1</labelIndex><name></name><selectedRelationships>success</selectedRelationships><source><groupId>53d29129-3b42-40ab-a008-81ebb557b334</groupId><id>70bb9f9d-0640-4122-bdc4-ce5e95cd27f6</id><type>PROCESSOR</type></source><zIndex>0</zIndex></connections><connections><id>ebac49b8-3b03-40f5-a658-f1034a300656</id><parentGroupId>53d29129-3b42-40ab-a008-81ebb557b334</parentGroupId><backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold><backPressureObjectThreshold>10000</backPressureObjectThreshold><destination><groupId>53d29129-3b42-40ab-a008-81ebb557b334</groupId><id>cd917fed-fbc3-4d58-9256-3bc21deeaaa0</id><type>PROCESSOR</type></destination><flowFileExpiration>0 sec</flowFileExpiration><labelIndex>1</labelIndex><name></name><selectedRelationships>success</selectedRelationships><source><groupId>53d29129-3b42-40ab-a008-81ebb557b334</groupId><id>4045eff6-fafc-4979-9138-b63d465c059a</id><type>PROCESSOR</type></source><zIndex>0</zIndex></connections><connections><id>dc85e5e7-564e-4d76-98b1-cd3434f5cc8f</id><parentGroupId>53d29129-3b42-40ab-a008-81ebb557b334</parentGroupId><backPressureDataSizeThreshold>1 GB</backPressureDataSizeThreshold><backPressureObjectThreshold>10000</backPressureObjectThreshold><destination><groupId>53d29129-3b42-40ab-a008-81ebb557b334</groupId><id>1aa2f6bc-8236-4592-bbc7-1385fed0f4e9</id><type>PROCESSOR</type></destination><flowFileExpiration>0 sec</flowFileExpiration><labelIndex>1</labelIndex><name></name><selectedRelationships>success</selectedRelationships><source><groupId>53d29129-3b42-40ab-a008-81ebb557b334</groupId><id>cd917fed-fbc3-4d58-9256-3bc21deeaaa0</id><type>PROCESSOR</type></source><zIndex>0</zIndex></connections><processors><id>4045eff6-fafc-4979-9138-b63d465c059a</id><parentGroupId>53d29129-3b42-40ab-a008-81ebb557b334</parentGroupId><position><x>1003.0298039347335</x><y>156.6821235311313</y></position><config><annotationData>&lt;criteria&gt;
&lt;flowFilePolicy&gt;USE_CLONE&lt;/flowFilePolicy&gt;
&lt;rules&gt;
&lt;actions&gt;
&lt;attribute&gt;var2&lt;/attribute&gt;
&lt;id&gt;a61c8ce1-a531-4862-bd81-ba9b97ac63cd&lt;/id&gt;
&lt;value&gt;${flowFileId}&lt;/value&gt;
&lt;/actions&gt;
&lt;actions&gt;
&lt;attribute&gt;var3&lt;/attribute&gt;
&lt;id&gt;0f004dd9-9f27-416d-b0f7-9176e21dc43a&lt;/id&gt;
&lt;value&gt;${nifi.system.properties.2}&lt;/value&gt;
&lt;/actions&gt;
&lt;actions&gt;
&lt;attribute&gt;var1&lt;/attribute&gt;
&lt;id&gt;e7082bf2-7608-44cb-bb17-40d4bdaa95a6&lt;/id&gt;
&lt;value&gt;${nifi.custom.variable.1}&lt;/value&gt;
&lt;/actions&gt;
&lt;conditions&gt;
&lt;expression&gt;${nifi.system.properties.1:equals(&quot;fake&quot;)}&lt;/expression&gt;
&lt;id&gt;7e83a780-86bc-4c87-b13d-997e14f19a52&lt;/id&gt;
&lt;/conditions&gt;
&lt;id&gt;38664ddc-41b7-4daf-9f04-6f4b336cbfd8&lt;/id&gt;
&lt;name&gt;Test Attribute&lt;/name&gt;
&lt;/rules&gt;
&lt;/criteria&gt;</annotationData><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>Delete Attributes Expression</key></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>0 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>UpdateAttribute</name><relationships><autoTerminate>false</autoTerminate><name>success</name></relationships><style/><type>org.apache.nifi.processors.attributes.UpdateAttribute</type></processors><processors><id>cd917fed-fbc3-4d58-9256-3bc21deeaaa0</id><parentGroupId>53d29129-3b42-40ab-a008-81ebb557b334</parentGroupId><position><x>1172.0298039347335</x><y>632.0221540487095</y></position><config><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>Attributes List</key><value>var1,var2,var3</value></entry><entry><key>Destination</key><value>flowfile-content</value></entry><entry><key>Include Core Attributes</key><value>true</value></entry><entry><key>Null Value</key><value>false</value></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>0 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>AttributesToJSON</name><relationships><autoTerminate>true</autoTerminate><name>failure</name></relationships><relationships><autoTerminate>false</autoTerminate><name>success</name></relationships><style/><type>org.apache.nifi.processors.standard.AttributesToJSON</type></processors><processors><id>70bb9f9d-0640-4122-bdc4-ce5e95cd27f6</id><parentGroupId>53d29129-3b42-40ab-a008-81ebb557b334</parentGroupId><position><x>389.9938542277023</x><y>586.3118928182407</y></position><config><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>File Size</key><value>100B</value></entry><entry><key>Batch Size</key><value>1</value></entry><entry><key>Data Format</key><value>Text</value></entry><entry><key>Unique FlowFiles</key><value>false</value></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>30 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>GenerateFlowFile</name><relationships><autoTerminate>false</autoTerminate><name>success</name></relationships><style/><type>org.apache.nifi.processors.standard.GenerateFlowFile</type></processors><processors><id>1aa2f6bc-8236-4592-bbc7-1385fed0f4e9</id><parentGroupId>53d29129-3b42-40ab-a008-81ebb557b334</parentGroupId><position><x>1782.0298039347335</x><y>254.2021235311313</y></position><config><bulletinLevel>WARN</bulletinLevel><comments></comments><concurrentlySchedulableTaskCount>1</concurrentlySchedulableTaskCount><lossTolerant>false</lossTolerant><penaltyDuration>30 sec</penaltyDuration><properties><entry><key>Directory</key><value>${nifi.custom.attributes.dir}</value></entry><entry><key>Conflict Resolution Strategy</key><value>fail</value></entry><entry><key>Create Missing Directories</key><value>true</value></entry><entry><key>Maximum File Count</key></entry><entry><key>Last Modified Time</key></entry><entry><key>Permissions</key></entry><entry><key>Owner</key></entry><entry><key>Group</key></entry></properties><runDurationMillis>0</runDurationMillis><schedulingPeriod>0 sec</schedulingPeriod><schedulingStrategy>TIMER_DRIVEN</schedulingStrategy><yieldDuration>1 sec</yieldDuration></config><name>PutFile</name><relationships><autoTerminate>true</autoTerminate><name>failure</name></relationships><relationships><autoTerminate>true</autoTerminate><name>success</name></relationships><style/><type>org.apache.nifi.processors.standard.PutFile</type></processors></snippet><timestamp>07/15/2016 18:59:09 EDT</timestamp></template>
# ensure this value provided in nifi.properties
nifi.variable.registry.properties=./conf/custom.properties,./conf/system.properties
nifi.system.properties.1=fake
nifi.system.properties.2=test
@akpuvvada
Copy link

Thanks for the good article. Very informative.
However, I am wondering if there is a way to make Nifi load the custom properties without restarting Nifi.

Thanks
Anil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment