开发者

Spring Batch resourceless JobRepository

I'm using Spring Batch for a system that does a lot of batch operations.

I'm using SimpleJobRepository with in memory DAOs.

I would like to know if there is a way to avoid using a JobRepository? something similar to the resourceless transaction manager?

The reason i'm asking is that the system should run constantly without restarting and i have some concerns about the memory it will be consuming.

I know i can use a database based JobRepositry, but frankly, I really don't need one a开发者_开发知识库t all.

If there is no way to do so i will appreciate it if someone can reassure me about the memory consumption problem.

Thanks.


You must use job repository as it holds info about the job context. the solution for your case is - make your job repository with scope="prototype" this will cerate a new in-memory dao (map implementation) for each job, and thus no memory problem. the overhead of creating new instance each time is meaningless in terms of batch jobs.


In-Memory implementation has a major drawback : you can't use multithreading in your batchs.

So you must use a database repository. I suggest you use H2 SQL : it's an embedded database very light. We use it for our unit tests.

It works very well with Hibernate.

The advantage of this method over Ben's one is you can connect to you memory database to check the jobs statuses (and date of launches, etc ...).


I think as long as my batch processing code is thread safe , it should not matter whether the Repository is in Memory or Database. Yes you might loose some of the clustering benefits which you can get if you are using DB but if I have only one Batch Job running on my server and its using Multiple threading to do its work, that should be fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜