문제

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 at 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top