Reputation: 1191
I know that jobs are useful to run a method in the start of the application (Bootstrap Job) and to run a method in a periodic interval of method (Scheduled Job).
But is there any other use of Jobs?
I mean, if I want to update the data in a database. In that case, do I want to write the code as a Job? If so, why are we doing that?
Please guide me on this.
I am using Play 1.2.5.
Thanks in advance.
Upvotes: 0
Views: 130
Reputation: 86
There are several uses of the jobs in play. They are well explained in the official documentation. I'll summarize the documentation with example usages.
database data insert
, loading Spring context
etc. batch db processing
, report generation
, daily reports
etc. data importing with progress status
. In this case, you should use class for persisting the progress status. persisting the cache data
, or other in-memory data, releasing some used resources
etc. In a regular database insert, I don't recommend using Job, since you should implement complicated techniques in order to obtain the result. As I mentioned earlier, if this task is very slow and you want to return the response faster, you can use a Job. Also, when you don't want to return the status of the database action (which is bad practice), and want to return the response faster, you can use Job. However, take care that the jobs are asynchronous and you must resolve the possible concurrency issues.
There are many more usages of the Jobs in Play (and in general) and it is impossible to cover them all, but I hope that this response will help you.
Upvotes: 2