i have a get function in my microservice which essentially fetchs data from a database. this function is running as a scheduler (cron job) and also as an api end point which can be triggered from the UI. i want to add some logic inside getData() which will only be executed when it is being triggered by the scheduler and
Tag: scheduled-tasks
Do I need synchronize method Scheduled method?
I have a Spring schedulled tasks which calls the same private method. Do I need to sync this method? Will I have the problem if shedulled tasks runned in the same time? Or will be better to extract it to the prototype component or separate schedulled classes or something else? Answer The default ThreadPoolTaskScheduler used by the @Scheduled annotation is,
Is there way to use @Scheduled together with Duration string like 15s and 5m?
I have following annotation in my code At this case I have to have properties like this Propery file looks unreadable because I have calculate value to miliseconds. Is there way to pass value like 5m or 30s there ? Answer As far as I know, you can’t do it directly. However, Spring boot configuration properties do support automatic conversion
How to stop a scheduled task that was started using @Scheduled annotation?
I have created a simple scheduled task using Spring Framework’s @Scheduled annotation. Now I want to stop this task, when no longer needed. I know there could be one alternative to check one conditional flag at the start of this method, but this will not stop execution of this method. Is there anything Spring provides to stop @Scheduled task ?
How to change Spring’s @Scheduled fixedDelay at runtime?
I have a requirement to run a batch job at a fixed interval and have the ability to change the time of this batch job at runtime. For this I came across @Scheduled annotation provided under Spring framework. But I’m not sure how I’d change the value of fixedDelay at runtime. I did some googling around but didn’t find anything