Skip to main content
techNerd
Silver ⭐️⭐️⭐️
October 11, 2023
Question

Reset the Filename sequence no./counter everyday

Hi,

Every 5 min i have a file generated from the NiFi Processor GenerateFlowFile:

filename_0.xml 

filename_1.xml

filename_2.xml

....

I would like to asked how do i reset the sequence no. everyday ?

Thanks. Would appreciate help with example and explanation. 

The first method i found is using nextInt():

techNerd_0-1697203874269.png

techNerd_1-1697203906116.png

the second method is using seq:

techNerd_2-1697204344772.pngtechNerd_3-1697204364634.png

Please advise me with steps and example. thanks

 

5 replies

drewski7
Gold ⭐️⭐️
October 11, 2023

Maybe you could reset the state via NiFi-REST-API at beginning of your flow or separately on a schedule cron every morning

Could be:
POST "https://[ip:port]/nifi-api/processors/${processor-id}/state/clear-requests"

 

This is the request which NiFi itself uses when you go to the processor in the UI and choose the menu-option "view state" -> "clear state".

Translate
techNerd
techNerdAuthor
Silver ⭐️⭐️⭐️
October 11, 2023

Hi @drewski7,

Thanks for the replying. 

From your reply, I have added in NiFi InvokeHTTP processor which will automatically help to reset my seq no. counter every morning.  I am using the second method above which using seq no. which store state locally. 

techNerd_0-1697126686575.png

techNerd_1-1697126955480.png

I have set the HTTP Method to POST and HTTP URL to https://[ip:port]/nifi-api/processors/${processor-id}/state/clear-requests 

techNerd_3-1697127005144.png

I have scheduled the NiFi InvokeHTTP Processor to run every morning 00:00 using CRON driven Scheduling Strategy 

techNerd_5-1697127267535.png

 

Below image are the NiFi UpdateAttribute Processor which show the processor ID that i used inside my HTTP URL

techNerd_4-1697127103612.png

Just to check did i did it correctly as what you mention in your reply ?

I tried to change my computer time to 11:55 pm and let it run to 00:00 the next day, but it does not invokeHTTP POST request once it reach 00:00. I might have made some mistake somewhere.

appreciate if you could advise me with example and explanation. Thanks a lot.  

 

Translate