I have a web-application (using spring mvc framework). It makes the following:
So, how I can do this with spring mvc framework? Thank You in Advance!
Use asynchronous marked method. You got example here:
https://spring.io/guides/gs/async-method/
and docs:
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html#scheduling
You can use JobRunr (https://github.com/jobrunr/jobrunr) in your controller. You should add Maven dependency jobrunr-spring-boot-starter. Then you can run your code on separate thread:
@Inject
private JobScheduler jobScheduler;
...
jobScheduler.enqueue(() -> someJobService.executeSampleJob());
For more details you can check: https://www.baeldung.com/java-jobrunr-spring
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With