I have an interesting requirement…and was wondering if you guys can think of a best way to implement this.
I have a auditTransaction service, which publishes an incoming document to the broker after checking some properties in a config file. The service which reads the config params is cached (lets call this serv2 which checks the properties). The publish to broker can be turned on or off from the config props file. Now, I want to make serv2 do the following.
- Somehow monitor the config params file.
- Reload the file everytime someone modifies it and refresh the cache.
Currently, I have scheduled this service to read the config file every 15 minutes and load any changes to the file. If the change to the properties file is made between the run interval, the service has to be manually run to load the changes. The problem with this is, sometimes the file will not change for days and, there is no need to check/reload the file every 15 mins. Reload is required only when the file changes.
Am I overthinking and complicating something that is very simple?
Did you find a solution to this ?
This would be my solution for the problem described.
(A)Configure a File poller from the Admin Screen and define the processing service.
- In the file name filter , you will give your complete file name as you want to monitor only one file. If you don’t specify a value it monitors all the files in the folder.
(B)Create a flow service (serv2 in your case)
Invoke a Java service(I don’t think there is any flow service for this requirement) which actually takes the file name as input , compares the last modified timestamp with the previous timestamp(if you store the previous timestamp somewhere in a config file or something), and the flag the output as true or false accordingly.
If “Yes” do the reload process , If “No” exit the flow service.
But all the above process is to be scheduled.
(C) 1. Monitor the file (again by comparing the timestamp)by writing a windows service in C# or .Net and have your flowservice (which just reloads the config file )called from the .Net Component , if there is a difference in the timestamp of the last modified value of the file.
Just my thoughts,
I implemented it kinda similar to what your option 2 was. It seems to be working fine.
Thanks for the response!