Filename in incremental fashion on subscribing side

Hi All,

I have a simple pub-sub scenario in which I am subscribing to a canonical document and I FTP the information in the canonical document to the client.The client has this condition that the remote filename should have numbers in incremental fashion.For eg:

When the first subscribtion comes, the file name should be info01.csv,the second one comes in it should be info02.csv …so on.

I am confused about this.Since every subscription calls a new thread , how am I gonna keep track of this file name iteration?

Any help is appreciated.

This is kind a odd requirement because if your client doesn’t want the old file to be overwritten then you could simply append the timestamp to the file name. Anyhow you can work around this requirement in few ways:

1 - You can use repository to store a value like 01 or 02 and everytime you are about to write the file on FTP server just pull that value increament it by one and overwrite it in the repository. Then you can append that to the file name.

2- You can do the same thing but store the value in database and overwrite for each file after incrementing.

3- If your client is keeping the file in the same directory then you can always get the list of files and tokenize it to get the last numbers and use the to create new file name.

I am sure there are other/better ways to do it. These are just on top of my head right now.

Thank you very much

Just be careful to do this in a thread-safe manner. If your subscriber is in serial mode, then it shouldn’t be much of a problem. If running in concurrent mode, you’ll need to serialize access to getting/updating the number to use.

If you have multiple IS instances, you’ll need a way to coordinate between them. And you’ll want to address failover scenarios.