-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScheduledDataLoaderService should load from remote and ignore resource cache #366
Comments
Do you feel checking once every 24h if the cached data is still there causes a performance problem or is too frequently? |
Lets to an example. ECB publishes exchange rates at 16:00 CET. The scheduler is configured by default in version 1.4.2 with 03:00 hours period. Assuming the process is started at 15:50 CET, the resource is loaded, but the exchange rate for the current day is not yet available, thus the resource returned is from the previous day. The scheduler will then 3 hours later at 18:50 try to check for an update. At least I thought that was the plan. But the scheduler will be blocked the next 24 hours by the internal cache of the You cannot control the behavior of the update with the scheduler unless the cache will be disabled or set to a very short amount that doesn't necessarily block the scheduler. |
Of course ECB is only one example of a provider, others may update exchange rates more often.
Is that the generic fallback or the default for ECB? |
I checked all ' javamoney.properties' files in And as you said, there might be providers who update more frequently, but the problem in my opinion stays the same. The |
I just checked the sources. There is a problem in the current snapshot of the |
I would suggest a simple fix: Instead of calling Otherwise I don't really understand what's the purpose of the scheduler here. It triggers the listeners even if the resource hasn't changed and therefore does parse the same data as before. |
Would you have a PR for that simple and easy fix? While for the Spec (JSR 354 API) we usually require contributors to also join the JCP in the RI unless you are happy to join, we are a bit more flexible. Of over 30 or so contributors only around half are JCP members. If someone contributes often, then it is advisable. |
The only thing I understood was PR, thanks to google telling me that's a 'pull request'. I haven't contributed to any open source github projects yet and I'm not familiar with the java community process (JCP). I will have to read more to understand what it is about. Please don't take it personal if you haven't got a PR yet :) |
No worries, thanks for the suggestion. I categorized the other one as ".Next" because if feels more like the next major version, while a few tweaks even changing the 3h to 13 or 23 could be done in the next minor version. |
We face the same problem. How exactly can the parameter be overwritten in javamoney.properties for the short term fix? Thank you in advance. |
@2kewl4u Any advice on that? |
As of version 1.4.2 the class
The properties are then used by the The Long story short:
Add these entries for each resource name that you want to configure. If you have trouble with this, simply place a breakpoint into the constructor of the |
@2kewl4u Thank you for the detailed explainatory reply. It was really helpful. |
@keilw hey i cloned the git repository and imported the projects from the master branch to try and provide some simple fixes for the current version as discussed. currently i fail to setup the project with maven error
Is there any guide or readme i can follow to setup the project on my machine? Thx for help. Kr |
Thanks for mentioning that, unless related to #370 it still has a slightly lower prio but for any build job I'll try to get the org.javamoney:moneta-parent:1.4.3-SNAPSHOT out to the repositories (only Sonatype now AFAIK) soon. |
The
ScheduledDataLoaderService
can be configured to schedule aTimerTask
to load theLoadableResource
and trigger theDefaultLoaderListener
. These listeners will parse the data from the resource and update their internal caches with newExchangeRate
objects.However, the scheduler will not load any new exchange rates and our data is most of the time outdated for a long time.
The reason is that there is actually a second level caching mechanism that prevents loading new data. The call to
LoadableResource.load()
will check if the resource has been loaded recently and in that case does not load from the remote source again.There is a property 'cacheTTLMillis' which is by default
Luckily this can be disabled in the 'javamoney.properties' file.
Besides that easy fix, there is no reason to configure the scheduler to regularly load the resource if the cache will prevent this from happening. I suggest that the
TimerTask
within theScheduledDataLoaderService
always reads from the remote source (and fallback if desired). An alternative would be to adjust the default value of 'cacheTTLMillis' to be somewhat compatible with the 'period' property of the scheduler.The text was updated successfully, but these errors were encountered: