views:

345

answers:

2

Hello,
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.

+1  A: 

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.

Ben
+1 Thanks - and accepted answer.
Nimrod Shory
A: 

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

Jean-Philippe Briend
I don't really need to check job statuses etc'.. If you can elaborate on why multithreading is a problem when using an in-memory job repository it will be great. Anyhow i want to reduce the memory usage so in memory DB is not a great option for me.
Nimrod Shory
In-Memory implementation is not thread safe, that's why you can't use it in conjonction with multithreading.
Jean-Philippe Briend