How to hold previous value if restart is taken

Hi Maxim/Thiomir

I have one query, I have written a CRON job it’s work is to read multiple text file and write that data to a CSV file. This read and write is performed via SFTP.

Created CSV File name : xyzA000101.csv

Where A0001 is seperate value and 01 is a seperate value

Now my scenario.

  1. My cron job is running at an interval of 2h, so whenever it will run it will create a file with the name format xyzA000101.csv

  2. So say my file sequence will follow the pattern.

xyzA000101.csv
xyzA000102.csv
xyzA000103.csv
__
__
xyzA000199.csv
xyzA000201.csv
__
__
xyzA000299.csv
xyzA000301.csv

  1. I am incrementing the value of A0001 and 01 equals to the number of times file created on SFTP.

  2. I have defined the counter inside activity.

  3. so if suppose because of some reason I have to take the restart then my counter value will be lost.

  4. And whenever I take a restart a new workflow of cron is created with new id.

So could you please suggest how can I retain my last counter value if restart is taken. Because I wanted to retain that last value and use it. Or I should not create a new cron every time I take a restart what is better for my solution please suggest.

Thanks!!

I have written a CRON job it’s work is to read multiple text file

How are you implementing the cron functionality? Are you using Temporal cron/schedules feature or are doing this in your workflow code explicitly via ContinueAsNew?

how can I retain my last counter value if restart is taken

Do you mean a worker restart here?

Hi @tihomir

I had implemented Cron using temporal functionality.

Yes Worker restart.

Store the progress in the activity heartbeat details. When a worker is restarted, the activity is retried after the heartbeat timeout and can access the details of the last heartbeat.